- Home /
[4.6] Toggle/Checkbox On/Off
How do I toggle the checkbox to show both on/off states. For example I want to enable something when checked and disable the same thing when unchecked. I have tried adding the toggle to the script by using public Toggle vsyncToggle; but that didn't let me add the object to it. I also have using UnityEngine.UI in my script. Any help?
Is this dynamically created menu or are you O$$anonymous$$ just adding the toggles to the canvas/panel yourself?
Either way you need to add them to a canvas group, but it'll make answer how you do the easier if I know what you're doing.
Oh and if it is being coded can you show the code, that helps as well.
Answer by Anxo · Jan 16, 2015 at 07:37 PM
bool someState = false;
void OnTogglePushed(){
someState = !someState;
someObjectToDisplay.SetActive(someState);
}
$$anonymous$$any thanks! Tweaked it slightly to my liking but worked :)
Your answer
Follow this Question
Related Questions
Toggle UI 4.6 0 Answers
Recreate Unity Editor Window in Game 0 Answers
[4.6 - UI] Calling function on button click via script 1 Answer
How to make a single word in a Text object clickable / have hover. 2 Answers
Cant access .interactable 1 Answer