本文介绍了如何在Unity中使用代码切换复选框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我查看了Toggle API,但找不到将其设置为通过代码检查的方法. http://docs.unity3d.com/ScriptReference/UI.Toggle.html

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?

谢谢!

推荐答案

http://docs.unity3d.com/ScriptReference/UI.Toggle-isOn.html

使用公共变量Toggle.isOn.像这样将其设置为true:myToggle.isOn = true;.

Use the public variable Toggle.isOn.Set it to true like this: myToggle.isOn = true;.

您可能正在寻找一种方法,但不要忘记也要查看公共变量,因为它们也是API的一部分.

You probably looked for a method, but don't forget to also look at the public variables, as these are part of the API as well.

这篇关于如何在Unity中使用代码切换复选框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 10:09