Hello,
I don’t understand why my dumb example bellow doesn’t work.
It works well but when I close Unity, the property value is reset. Anyone could help me ?
My custom class :
[Serializable]
public class MyCustomClass : MonoBehaviour{
[SerializeField]
public object obj = false;
}
My custom editor:
[CustomEditor(typeof(MyCustomClass), true)]
public class testeditor : Editor{
private MyCustomClass _myClass;
public void OnEnable () {
this._myClass = (MyCustomClass) target;
}
public override void OnInspectorGUI () {
EditorGUI.BeginChangeCheck();
//Undo.RecordObject(this._myClass, "MyClasse change"); => Why it doesn't work ?
this._myClass.obj = EditorGUILayout.Toggle("Selected", (bool)this._myClass.obj);
if (EditorGUI.EndChangeCheck ()) {
// I use this because Undo.RecordObject() doesn't work
EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
}
}
}