Don't like ads? PRO users don't see any ads ;-)
Guest

Creating ScriptableObjects

By: AnomalousUnderdog on Aug 2nd, 2012  |  syntax: C#  |  size: 0.56 KB  |  hits: 24  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.                         string newName = "NewHitscanWeapon";
  2.                         HitScanWeaponDefinition newDef = ScriptableObject.CreateInstance<HitScanWeaponDefinition>(); // HitScanWeaponDefinition is my ScriptableObject class
  3.                         newDef.name = newName;
  4.                         AssetDatabase.CreateAsset(newDef, _lastAssetPath + "/" + newName + ".asset"); // _lastAssetPath's value is the path of the last folder the user clicked on in the Project View
  5.                         Selection.activeObject = newDef;
  6.                         EditorUtility.FocusProjectWindow();
  7.                         Debug.Log("Created new hitscan weapon file at: " + AssetDatabase.GetAssetPath(newDef));