UnityAPI手册-2019.4官网版
文集大纲加载中……
本文档使用 MrDoc 发布
-
+
首页
GUILayout.Toggle
# [GUILayout](https://docs.unity3d.com/cn/2019.4/ScriptReference/GUILayout.html).Toggle public static bool **Toggle** (bool **value**, [Texture](https://docs.unity3d.com/cn/2019.4/ScriptReference/Texture.html) **image**, params GUILayoutOption[] **options**); public static bool **Toggle** (bool **value**, string **text**, params GUILayoutOption[] **options**); public static bool **Toggle** (bool **value**, [GUIContent](https://docs.unity3d.com/cn/2019.4/ScriptReference/GUIContent.html) **content**, params GUILayoutOption[] **options**); public static bool **Toggle** (bool **value**, [Texture](https://docs.unity3d.com/cn/2019.4/ScriptReference/Texture.html) **image**, [GUIStyle](https://docs.unity3d.com/cn/2019.4/ScriptReference/GUIStyle.html) **style**, params GUILayoutOption[] **options**); public static bool **Toggle** (bool **value**, string **text**, [GUIStyle](https://docs.unity3d.com/cn/2019.4/ScriptReference/GUIStyle.html) **style**, params GUILayoutOption[] **options**); public static bool **Toggle** (bool **value**, [GUIContent](https://docs.unity3d.com/cn/2019.4/ScriptReference/GUIContent.html) **content**, [GUIStyle](https://docs.unity3d.com/cn/2019.4/ScriptReference/GUIStyle.html) **style**, params GUILayoutOption[] **options**); ## 参数 | value | 该按钮是打开还是关闭? | | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | text | 要在按钮上显示的文本。 | | image | 要在按钮上显示的 [Texture](https://docs.unity3d.com/cn/2019.4/ScriptReference/Texture.html)。 | | content | 该按钮的文本、图像和工具提示。 | | style | 要使用的样式。如果省略,则使用当前 [GUISkin](https://docs.unity3d.com/cn/2019.4/ScriptReference/GUISkin.html) 的 `button` 样式。 | | options | (可选)一个布局选项列表,用于指定额外的布局属性。此处传递的任何值都将覆盖 `style` 定义的设置。另请参阅:[GUILayout.Width](https://docs.unity3d.com/cn/2019.4/ScriptReference/GUILayout.Width.html)、[GUILayout.Height](https://docs.unity3d.com/cn/2019.4/ScriptReference/GUILayout.Height.html)、[GUILayout.MinWidth](https://docs.unity3d.com/cn/2019.4/ScriptReference/GUILayout.MinWidth.html)、[GUILayout.MaxWidth](https://docs.unity3d.com/cn/2019.4/ScriptReference/GUILayout.MaxWidth.html)、[GUILayout.MinHeight](https://docs.unity3d.com/cn/2019.4/ScriptReference/GUILayout.MinHeight.html)、 [GUILayout.MaxHeight](https://docs.unity3d.com/cn/2019.4/ScriptReference/GUILayout.MaxHeight.html)、[GUILayout.ExpandWidth](https://docs.unity3d.com/cn/2019.4/ScriptReference/GUILayout.ExpandWidth.html)、[GUILayout.ExpandHeight](https://docs.unity3d.com/cn/2019.4/ScriptReference/GUILayout.ExpandHeight.html)。 | ## 返回 **bool** 按钮的新值。 ## 描述 创建一个打开/关闭的开关按钮。  \ *游戏视图中的切换按钮。* ``` using UnityEngine; public class ExampleScript : MonoBehaviour { // Draws 2 toggle controls, one with a text, the other with an image. Texture aTexture; bool toggleTxt = false; bool toggleImg = false; void OnGUI() { if (!aTexture) { Debug.LogError("Please assign a texture in the inspector."); return; } toggleTxt = GUILayout.Toggle(toggleTxt, "A Toggle text"); toggleImg = GUILayout.Toggle(toggleImg, aTexture); } } ```
da
2022年6月10日 00:16
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
关于 MrDoc
觅思文档MrDoc
是
州的先生
开发并开源的在线文档系统,其适合作为个人和小型团队的云笔记、文档和知识库管理工具。
如果觅思文档给你或你的团队带来了帮助,欢迎对作者进行一些打赏捐助,这将有力支持作者持续投入精力更新和维护觅思文档,感谢你的捐助!
>>>捐助鸣谢列表
微信
支付宝
QQ
PayPal
Markdown文件
分享
链接
类型
密码
更新密码