Объявление
public static bool RepeatButton(Rect position, string text);public static bool RepeatButton(Rect position, Texture image);
public static bool RepeatButton(Rect position, GUIContent content);
public static bool RepeatButton(Rect position, string text, GUIStyle style);
public static bool RepeatButton(Rect position, Texture image, GUIStyle style);
public static bool RepeatButton(Rect position, GUIContent content, GUIStyle style);
Параметры
position | Прямоугольник на экране для кнопки. |
text | Текст для отображения на кнопке. |
image | Текстура для отображения на кнопке. |
content | Текст, изображение и всплывающая подсказка для этой кнопки. |
style | Используемый стиль. Если не указать, будет использоваться стиль кнопки из текущего GUISkin. |
Возвращает
bool true, когда пользователи нажимают кнопку.
Описание
Сделайте кнопку, которая активна, пока пользователь держит ее нажатой.
// Рисует 2 кнопки, одну с изображением, другую с текстом
// Печатает сообщение, когда на них нажимают.
// Печатает сообщение, когда на них нажимают.
using UnityEngine;
using System.Collections;
public class Example : MonoBehaviour
{
public Texture btnTexture;
void OnGUI()
{
if (!btnTexture)
{
Debug.LogError("Please assign a texture on the inspector");
return;
}
if (GUI.RepeatButton(new Rect(10, 10, 50, 50), btnTexture))
Debug.Log("Clicked the button with an image");
if (GUI.RepeatButton(new Rect(10, 70, 50, 30), "Click"))
Debug.Log("Clicked the button with text");
}
}