GUI.Label

Unity · Версия 2020.3 LTS · Scripting · GUI

GUI.Label

Объявление

public static void Label(Rect position, string text);

public static void Label(Rect position, Texture image);

public static void Label(Rect position, GUIContent content);

public static void Label(Rect position, string text, GUIStyle style);

public static void Label(Rect position, Texture image, GUIStyle style);

public static void Label(Rect position, GUIContent content, GUIStyle style);

Параметры

position Прямоугольник на экране для использования в качестве метки.
text Текст для отображения на этикетке.
image Текстура для отображения на этикетке.
content Текст, изображение и всплывающая подсказка для этого ярлыка.
style Используемый стиль. Если его не указать, используется стиль label из текущего GUISkin.

Описание

Make a text or texture label on screen.

Labels have no user interaction, do not catch mouse clicks and are always rendered in normal style. If you want to make a control that responds visually to user input, use a Box control.

Example: Draw the classic Hello World! string:

Текстовая метка в Game View.
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour
{
    void OnGUI()
    {
        GUI.Label(new Rect(10, 10, 100, 20), "Hello World!");
    }
}

Example: Draw a texture on-screen. Labels are also used to display textures, instead of a string, simply pass in a texture:

Текстурная этикетка.
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour
{
    public Texture2D textureToDisplay;

    void OnGUI()
    {
        GUI.Label(new Rect(10, 40, textureToDisplay.width, textureToDisplay.height), textureToDisplay);
    }
}

Обновлено 17 ноября 2026 г.