GUI

您所在的位置:网站首页 unity按钮打开悬浮窗口设置 GUI

GUI

2024-06-18 17:17| 来源: 网络整理| 查看: 265

GUI.Button 切换到手册 public static bool Button (Rect position, string text); public static bool Button (Rect position, Texture image); public static bool Button (Rect position, GUIContent content); public static bool Button (Rect position, string text, GUIStyle style); public static bool Button (Rect position, Texture image, GUIStyle style); public static bool Button (Rect position, GUIContent content, GUIStyle style); 参数 position 屏幕上用于按钮的矩形。 text 要在按钮上显示的文本。 image 要在按钮上显示的 Texture。 content 该按钮的文本、图像和工具提示。 style 要使用的样式。如果省略,则使用当前 GUISkin 的 button 样式。 返回

bool 当用户单击该按钮时,返回 /true/。

描述

创建一个单击按钮。当用户点击该按钮时,立即执行一些操作。

// Draws 2 buttons, one with an image, and other with a text // And print a message when they got clicked.using UnityEngine; using System.Collections;public class ExampleClass : MonoBehaviour { public Texture btnTexture; void OnGUI() { if (!btnTexture) { Debug.LogError("Please assign a texture on the inspector"); return; } if (GUI.Button(new Rect(10, 10, 50, 50), btnTexture)) Debug.Log("Clicked the button with an image"); if (GUI.Button(new Rect(10, 70, 50, 30), "Click")) Debug.Log("Clicked the button with text"); } }


【本文地址】


今日新闻


推荐新闻


    CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3