Add JsonAsset::GetInstance<T> for easier access to C++ json asset data

This commit is contained in:
Wojtek Figat
2021-09-23 13:47:44 +02:00
parent 8d512eb1d3
commit 76a4d0652f
2 changed files with 11 additions and 0 deletions

View File

@@ -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]