Add JsonAsset::GetInstance<T> for easier access to C++ json asset data
This commit is contained in:
@@ -93,6 +93,16 @@ public:
|
||||
/// </summary>
|
||||
void* Instance;
|
||||
|
||||
/// <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>
|
||||
template<typename T>
|
||||
T* GetInstance() const
|
||||
{
|
||||
return Instance && InstanceType.IsAssignableFrom(T::TypeInitializer) ? (T*)Instance : nullptr;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
// [JsonAssetBase]
|
||||
|
||||
Reference in New Issue
Block a user