Hi, I made a custom editor and it behaves weird.
I created something like this :
[CustomEditor(typeof(MyCustomClass))]
public class MyCustomClassEditor : Editor{
bool myBool = false;
void OnInspectorGUI(){
DrawDefaultInspector();
if(myBool){
if(GUILayout.Button("Disable")){
myBool = false;
//DO SOMETHING
}
}else{
if(GUILayout.Button("Enable")){
myBool = true;
//DO SOMETHING
}
}
}
void OnSceneGUI(){
if(myBool){
//DRAW SOMETHING ON THE SCENE WINDOW
}
}
}
this creates a button in the inspector that toggles the boolean myBool. And it affects the way the OnSceneGUI() behaves.
In fact, it worked without any trouble yesterday, but when I come back for work, it does not work anymore. I tried to figure out what causes the problem, I added a debug script
Debug.Log("Inspector myBool : "+myBool); => OnInspectorGUI()
Debug.Log("Scene myBool : " +myBool); => OnSceneGUI()
and here is what I have found :
From OnInspectorGUI() the value changes with respect to the button click.
But OnSceneGUI() the value is fixed to false. Even if the value from the OnInspectorGUI() is true, OnScenGUI() shows false. and those value exist simultaneously.
What the… is this a Schrödinger’s boolean???