Version: 2017.2

GUIContentConstructor

Switch to Manual
public GUIContent ();

Description

Конструктор для GUIContent всех форм и размеров.

Создает пустой GUIContent.


public GUIContent (string text);

Description

Создает объект GUIContent, содержащий только текст.

При использовании GUI не обязательно создавать GUIContents для простого текста - две строки кода обеспечат данный функционал:

using UnityEngine;
using System.Collections;

public class ExampleClass : 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);

Description

Создает объект GUIContent, содержащий только изображение.

using UnityEngine;
using System.Collections;

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

public GUIContent (string text, Texture image);

Description

Создает объект GUIContent, содержащий и текст, и изображение.

using UnityEngine;
using System.Collections;

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

public GUIContent (string text, string tooltip);

Description

Создает GUIContent, содержащий некоторый текст. Когда пользователь наводит на него мышь, глобальная GUI.tooltip устанавливается в tooltip.

using UnityEngine;
using System.Collections;

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

public GUIContent (Texture image, string tooltip);

Description

Создает GUIContent, содержащий изображение. Когда пользователь наводит на него мышь, глобальная GUI.tooltip устанавливается в tooltip.


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

Description

Создает GUIContent, содержащий текст text, изображение image и имеющий определенную подсказку tooltip . Когда пользователь наводит на него мышь, глобальная GUI.tooltip устанавливается в tooltip.


public GUIContent (GUIContent src);

Description

Создает GUIContent как копию другого GUIContent'а.

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