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(); }
void Add() { var cap = ScriptableObject.CreateInstance <MotorCapacity>(); cap.name = "MotorCapacity"; m_capacity = cap; UnityEditor.AssetDatabase.AddObjectToAsset(cap, UnityEditor.AssetDatabase.GetAssetPath(gameObject)); UnityEditor.AssetDatabase.SaveAssets(); }