Version: 2018.1
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ラベル上に表示する Texture
contentラベルのテキスト、画像、ツールチップ
style使用するスタイル。省略された場合は、現在の GUISkin にある label スタイルを使用します。

説明

スクリーン上のテキストやテクスチャのラベルを作成します

ラベルはマウスクリックのイベントを取得しない、つまりユーザーインタラクションを持たず、ノーマルスタイルでレンダリングされます。ユーザー入力を視覚的に応答するコントロールを作成する場合は、Box を使用してください。

例: 典型的な「 Hello World!」の文字を描画


Text label on the Game View.

using UnityEngine;
using System.Collections;

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

例: 画面上にテクスチャを描画します。ラベルにテクスチャを文字列の代わりに渡すだけでテクスチャが表示されます。


Texture Label.

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); } }