コード例 #1
0
        void Remove()
        {
            var path = UnityEditor.AssetDatabase.GetAssetPath(gameObject);
            var cap  = System.Array.Find(UnityEditor.AssetDatabase.LoadAllAssetsAtPath(path), (it) => (it is MotorCapacity));

            UnityEngine.Object.DestroyImmediate(cap, true);
            m_capacity = null;

            UnityEditor.AssetDatabase.SaveAssets();
        }
コード例 #2
0
        void Add()
        {
            var cap = ScriptableObject.CreateInstance <MotorCapacity>();

            cap.name   = "MotorCapacity";
            m_capacity = cap;
            UnityEditor.AssetDatabase.AddObjectToAsset(cap, UnityEditor.AssetDatabase.GetAssetPath(gameObject));

            UnityEditor.AssetDatabase.SaveAssets();
        }