@@ -14,6 +14,17 @@ namespace FlaxEngine
|
||||
/// </summary>
|
||||
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>
|
||||
/// Creates a new instance of the serialized object from the json asset data.
|
||||
/// </summary>
|
||||
|
||||
@@ -33,6 +33,15 @@ namespace FlaxEngine
|
||||
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>
|
||||
/// Implicit cast operator.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user