private static void RemoveChildScriptableObject() { CParentScriptableObject parent = UnityEditor.AssetDatabase.LoadAssetAtPath <CParentScriptableObject>(PATH); Object.DestroyImmediate(parent.childScriptableObject, true); parent.childScriptableObject = null; UnityEditor.AssetDatabase.ImportAsset(PATH); }
private static void CreateScriptableObject() { CParentScriptableObject parent = ScriptableObject.CreateInstance <CParentScriptableObject>(); parent.childScriptableObject = ScriptableObject.CreateInstance <CChildScriptableObject>(); parent.childScriptableObject.name = "new Child"; parent.childScriptableObject.hideFlags = HideFlags.HideInHierarchy; UnityEditor.AssetDatabase.AddObjectToAsset(parent.childScriptableObject, PATH); UnityEditor.AssetDatabase.CreateAsset(parent, PATH); UnityEditor.AssetDatabase.ImportAsset(PATH); }