Search Unity

Question GUI Toggle Deactivates On Window Close

Discussion in 'Editor & General Support' started by Controser, Apr 8, 2020.

  1. Controser

    Controser

    Joined:
    Feb 3, 2018
    Posts:
    9
    I had a quick question regarding Unity Editor Windows and wondered if anyone could help me or point me to someone who could. I made a gui toggle but when it is selected and you close the window, the next time you open the window it is unselected. Is there a way to make it stay on if clicked?

    Code (CSharp):
    1. public bool DarkMode { get; private set; }
    2.  
    3. DarkMode = EditorGUILayout.ToggleLeft("Enable Dark Mode", DarkMode);
    4.  
    5.             if (DarkMode)
    6.                 GUI.backgroundColor = new Color32(60, 60, 60, 255);
    7.             else
    8.                 GUI.backgroundColor = Color.white;
    I wrote the code to change my text blocks to a dark grey if the toggle is selected