ScriptReference/ScriptableObject.CreateInstance #261
Replies: 1 comment 1 reply
-
|
If you're creating the ScriptableObject manually (not with the CreateAssetMenuAttribute) then make sure you call AssetDatabase.CreateAsset() etc: public static void CreateAsset<T> (string path) where T : ScriptableObject
{
T asset = ScriptableObject.CreateInstance<T> ();
string assetPathAndName = AssetDatabase.GenerateUniqueAssetPath(path + "/New " + typeof(T).ToString() + ".asset");
AssetDatabase.CreateAsset(asset, assetPathAndName);
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
ScriptReference/ScriptableObject.CreateInstance
https://docs.unity3d.com/ScriptReference/ScriptableObject.CreateInstance.html
Beta Was this translation helpful? Give feedback.
All reactions