I'm just learning C# and Unity and I'm having a hell of a time trying to figure out the proper syntax here:
var assets = AssetDatabase.LoadAllAssetsAtPath(AssetDatabase.GetAssetPath(this));
foreach (var a in assets)
{
if (a == null)
{
var asset = CreateInstance<a.GetType()>();
asset.name = "Stats";
asset.Instantiate(this);
AssetDatabase.AddObjectToAsset(asset, this);
}
}
My issue is the var asset = CreateInstance<a.GetType()>();
I'm trying create instances of multiple scriptable objects and assign them to a parent scriptable object, but I can't seem to get the target object type in a way that CreateInstance<Type>() will accept. Can anyone help me out here?