This page has been translated automatically.
Видеоуроки
Интерфейс
Основы
Продвинутый уровень
Подсказки и советы
Основы
Программирование на C#
Рендеринг
Профессиональный уровень (SIM)
Принципы работы
Свойства (properties)
Компонентная Система
Рендер
Режимы вывода изображения
Физика
Браузер SDK 2
Лицензирование и типы лицензий
Дополнения (Add-Ons)
Демонстрационные проекты
API Samples
Редактор UnigineEditor
Обзор интерфейса
Работа с ассетами
Контроль версий
Настройки и предпочтения
Работа с проектами
Настройка параметров ноды
Setting Up Materials
Настройка свойств
Освещение
Sandworm
Использование инструментов редактора для конкретных задач
Расширение функционала редактора
Встроенные объекты
Ноды (Nodes)
Объекты (Objects)
Эффекты
Декали
Источники света
Geodetics
World-ноды
Звуковые объекты
Объекты поиска пути
Player-ноды
Программирование
Основы
Настройка среды разработки
Примеры использования
C++
C#
UnigineScript
Унифицированный язык шейдеров UUSL (Unified UNIGINE Shader Language)
Плагины
Форматы файлов
Материалы и шейдеры
Rebuilding the Engine Tools
Интерфейс пользователя (GUI)
Двойная точность координат
API
Animations-Related Classes
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
VR-Related Classes
Работа с контентом
Оптимизация контента
Материалы
Визуальный редактор материалов
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Учебные материалы

Unigine.WidgetButton Class

Inherits from: Widget

Interface for widget button handling.

The object of this class looks as follows:

Here is an example of two buttons. Button1 has a background and image, Button2 is without them:

Notice
The button is automatically stretched or shrinked to match the size of the current texture/image. When you resize the button the size of the image does not change. In case you need to create a type of button widget with an auto-adjusted image size, or image rotation, please consider Widget Sprite instead.

See Also#

  • Widgets sample in C# Component Samples suite
  • UnigineScript API sample <UnigineSDK>/data/samples/widgets/button_00

Example#

The following code illustrates how to create a button widget and set its parameters.

Source code (C#)
/* .. */

// event handler function
void OnButtonClicked()
{
	/* .. */
	
	return;
}

/* .. */
 public override bool Init()
{
	// getting a pointer to the system GUI
	Gui gui = Gui.GetCurrent();

	// creating a button widget and setting its caption
	WidgetButton widget_button = new WidgetButton(gui, "Delete");

	// setting a tooltip
	widget_button.SetToolTip("Delete object(s)");

	// rearranging button size
	widget_button.Arrange();

	// setting button position
	widget_button.SetPosition(10, 10);

	// setting onButtonClicked function to handle CLICKED event
	widget_button.EventClicked.Connect(OnButtonClicked);

	// adding created button widget to the system GUI
	gui.AddChild(widget_button, Gui.ALIGN_OVERLAP | Gui.ALIGN_FIXED);
}

WidgetButton Class

Properties

string StyleTexture#

The path to the button skin texture.

string Text#

The button text label.

int TextAlign#

The alignment of the button label.

string Texture#

The path to the button image texture.
Notice
The button is automatically stretched or shrinked to match the size of the current texture. When you resize the button the size of the image does not change. In case you need to create a type of button widget with an auto-adjusted image size, or image rotation, please consider Widget Sprite instead.

vec4 ButtonColor#

The color for the button.

bool Toggled#

The value indicating if the toggle button is pressed.

bool Toggleable#

The value indicating if the button is a toggle button or a simple one. The default is 0.

int Background#

The value indicating if a background texture is rendered for the button. The default is 1.

Members


WidgetButton ( Gui gui, string str = 0 ) #

Constructor. Creates a button with a given label and adds it to the specified GUI.

Arguments

  • Gui gui - GUI, to which the new button will belong.
  • string str - Button label. This is an optional parameter.

WidgetButton ( string str = 0 ) #

Constructor. Creates a button with a given label and adds it to the Engine GUI.

Arguments

  • string str - Button label. This is an optional parameter.

void SetImage ( Image image ) #

Sets a new image for the button.
Notice
The button is automatically stretched or shrinked to match the size of the current image. When you resize the button the size of the image does not change. In case you need to create a type of button widget with an auto-adjusted image size, or image rotation, please consider Widget Sprite instead.

Arguments

  • Image image - Image to set.

Image GetImage ( ) #

Returns the current button image.
Notice
The button is automatically stretched or shrinked to match the size of the current image. When you resize the button the size of the image does not change. In case you need to create a type of button widget with an auto-adjusted image size, or image rotation, please consider Widget Sprite instead.

Return value

Button image.

void SetStyleImage ( Image image ) #

Sets a button skin image.

Arguments

  • Image image - Image to set.

Image GetStyleImage ( ) #

Returns the button skin image.

Return value

Button skin image.
Last update: 13.12.2024
Build: ()