I created a custom Inspector for some of my ScriptableObject. The inspector seems to work perfectly. If a value gets changed in the inspector, this value is used in game. But as soon as I restart Unity the value is back on its old value, so the changed are not applied to the file. I have checked that by looking in the file. Here is my custom Inspector:
[CustomEditor(typeof(ScriptableObjects.OBJ))]
public class OBJEditor: UnityEditor.Editor {
public override void OnInspectorGUI() {
_ = DrawDefaultInspector();
ScriptableObjects.OBJ obj = (ScriptableObjects.OBJ) target;
obj.Offset = EditorGUILayout.Vector2Field("Offset", obj.Offset);
...
EditorUtility.SetDirty(obj);
}
}
I have added the line EditorUtility.SetDirty(bc);
because I have read that this line should apply changes to the file. The ...
stand for some other lines that are pretty much the same as the two lines above the dots.
How can I save my changes to the ScriptableObject file.