Unity/Editor
ScriptableObject
잉여씨
2018. 11. 29. 12:36
ScriptableObject
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | using UnityEditor; using UnityEngine; public class CharacterInfoEditor { [MenuItem("Assets/Sample/example")] public static void CreateExampleAsset() { var exampleAsset = ScriptableObject.CreateInstance<Example>(); string path = AssetDatabase.GetAssetPath(Selection.activeObject); if (string.IsNullOrEmpty(path)) { AssetDatabase.CreateAsset(exampleAsset, "Assets/Example.asset"); } else { AssetDatabase.CreateAsset(exampleAsset, path + "/Example.asset"); } AssetDatabase.Refresh(); } } | cs |
Attribute 이용
1 2 3 4 5 6 7 | using UnityEngine; [CreateAssetMenu( menuName = "MyGame/Create ParameterTable", fileName = "ParameterTable" )] public class ParameterTable : ScriptableObject { } // class ParameterTable | cs |