How do I toggle a checkbox in Unity with code?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I looked at the Toggle API and can't find a way to set it to checked with code. http://docs.unity3d.com/ScriptReference/UI.Toggle.html The reason I want to do it is that I want to set a checkbox as checked depending on a setting when the game starts. Any ideas on how to do this? Thanks! 回答1: http://docs.unity3d.com/ScriptReference/UI.Toggle-isOn.html Use the public variable Toggle.isOn . Set it to true like this: myToggle.isOn = true; . You probably looked for a method, but don't forget to also look at the public variables, as these are part