@@ -14,6 +14,17 @@ namespace FlaxEngine
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public object Instance => _instance ?? (_instance = CreateInstance());
|
public object Instance => _instance ?? (_instance = CreateInstance());
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the instance of the serialized object from the json data. Cached internally.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The asset instance object or null.</returns>
|
||||||
|
public T GetInstance<T>()
|
||||||
|
{
|
||||||
|
if (Instance is T instance)
|
||||||
|
return instance;
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new instance of the serialized object from the json asset data.
|
/// Creates a new instance of the serialized object from the json asset data.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -33,6 +33,15 @@ namespace FlaxEngine
|
|||||||
Asset = asset;
|
Asset = asset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the deserialized native object instance of the given type. Returns null if asset is not loaded or loaded object has different type.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The asset instance object or null.</returns>
|
||||||
|
public U GetInstance<U>()
|
||||||
|
{
|
||||||
|
return Asset ? Asset.GetInstance<U>() : default(U);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Implicit cast operator.
|
/// Implicit cast operator.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user