- Home /
how to turn a GUI toggle on/off from a script
I am making a puzzle based game that has a toggle that needs to be in the "on state" after every level. How exactly should I do this?
Answer by Xarbrough · Mar 11, 2018 at 01:00 AM
This sounds like you could use the help of some tutorials. For example the Unity Learn Site about User Interface. You could work through one of the series like this one about a Tic-Tac-Toe game to get an understanding of how the UI system works.
I know that you've written "GUI", so I should clear up, that GUI refers to the old legacy immediate mode GUI system of Unity, which shouldn't be used anymore outside of editor scripting. Instead, we have the component-based UI system since Unity 4.6.
There's a UI Toggle component to do what you want, once you understand how the system works. You want to set the isOn property.
Your answer
Follow this Question
Related Questions
GetKeyDown Bug 1 Answer
On button toggle, left click returns object name. 1 Answer
3 sets of button activations GUI 1 Answer
Is there a multiple selection ugui toggle group? 1 Answer
GUI toggle on click, unless on GUI. 1 Answer