Version: 2020.1

GUIContentConstructor

切换到手册
public GUIContent ();

描述

所有形状和大小的 GUIContent 的构造函数。

构建一个空的 GUIContent。


public GUIContent (string text);

描述

构建一个仅包含文本的 GUIContent 对象。

使用 GUI 时,不必为简单文本字符串创建 GUIContent - 以下两行代码具有相同的功能:

using UnityEngine;

public class ExampleScript : MonoBehaviour { void OnGUI() { GUI.Button(new Rect(0, 0, 100, 20), "Click Me"); GUI.Button(new Rect(0, 30, 100, 20), new GUIContent("Click Me")); } }

public GUIContent (Texture image);

描述

构建一个仅包含图像的 GUIContent 对象。

using UnityEngine;

public class ExampleScript : MonoBehaviour { public Texture icon; void OnGUI() { GUI.Button(new Rect(0, 30, 100, 20), new GUIContent(icon)); } }

public GUIContent (string text, Texture image);

描述

构建一个包含/文本/及图像的 GUIContent 对象。

using UnityEngine;

public class ExampleScript : MonoBehaviour { public Texture icon; void OnGUI() { GUI.Button(new Rect(0, 30, 100, 20), new GUIContent("Click me", icon)); } }

public GUIContent (string text, string tooltip);

描述

构建一个包含一些/文本/的 GUIContent。当用户将鼠标悬停在它上面时,将全局 GUI.tooltip 设置为该/工具提示/。

using UnityEngine;

public class ExampleScript : MonoBehaviour { void OnGUI() { GUI.Button(new Rect(0, 0, 100, 20), new GUIContent("Click me", "This is the tooltip"));

// If the user hovers the mouse over the button, the global tooltip gets set GUI.Label(new Rect(0, 40, 100, 40), GUI.tooltip); } }

public GUIContent (Texture image, string tooltip);

描述

构建一个包含图像的 GUIContent。当用户将鼠标悬停在它上面时,将全局 GUI.tooltip 设置为该/工具提示/。


public GUIContent (string text, Texture image, string tooltip);

描述

构建一个包含/文本/、图像并定义了/工具提示/的 GUIContent。当用户将鼠标悬停在它上面时,将全局 GUI.tooltip 设置为该/工具提示/。


public GUIContent (GUIContent src);

描述

将 GUIContent 构建为另一个 GUIContent 的副本。

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961