
Creating ScriptableObjects
By:
AnomalousUnderdog on
Aug 2nd, 2012 | syntax:
C# | size: 0.56 KB | hits: 24 | expires: Never
string newName = "NewHitscanWeapon";
HitScanWeaponDefinition newDef = ScriptableObject.CreateInstance<HitScanWeaponDefinition>(); // HitScanWeaponDefinition is my ScriptableObject class
newDef.name = newName;
AssetDatabase.CreateAsset(newDef, _lastAssetPath + "/" + newName + ".asset"); // _lastAssetPath's value is the path of the last folder the user clicked on in the Project View
Selection.activeObject = newDef;
EditorUtility.FocusProjectWindow();
Debug.Log("Created new hitscan weapon file at: " + AssetDatabase.GetAssetPath(newDef));