Version: 2017.2
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);

Parameters

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

Returns

bool @return true при клике по данной кнопке.

Description

Создает одну кнопку. Пользователь щелкает по ней и сразу же что-то происходит.

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