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


'Unity > Editor' 카테고리의 다른 글

Editor코드로 Button에 OnClick 리스너 설정하기  (0) 2018.12.06
ReorderableList  (0) 2018.11.29
Unity 실행 시 에디터 스크립트 코드 실행  (0) 2018.11.21
트리뷰(TreeView)  (0) 2018.11.21
커스텀 에디터(CustomEditor)  (0) 2018.11.21

+ Recent posts