I just started experimenting with a custom EditorWindow and I added a simple toggle button to enable/disable MeshRenderer.enable. Everything works just fine, however, after returning from playmode, the state of the button still persists. I thought everything got serialized and restored when returning to Edit mode? At least that’s what happened to the MeshRenderer.enable. How can I restore the state of the toggle button pre-Playmode so everything is in sync?
Here’s the sample:
public class TestEditor : EditorWindow
{
private bool EnableButton = true;
void OnGUI()
{
EnableButton = EditorGUILayout.Toggle("ToggleMesh", EnableButton);
dosomething();
}
}