This page has been translated automatically.
视频教程
界面
要领
高级
实用建议
UnigineEditor
界面概述
资产工作流程
设置和首选项
项目开发
调整节点参数
Setting Up Materials
Setting Up Properties
照明
Landscape Tool
Sandworm (Experimental)
使用编辑器工具执行特定任务
Extending Editor Functionality
嵌入式节点类型
Nodes
Objects
Effects
Decals
Light Sources
Geodetics
World Objects
Sound Objects
Pathfinding Objects
Players
编程
基本原理
搭建开发环境
Usage Examples
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine Tools
GUI
双精度坐标
应用程序接口
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
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

Unigine.WidgetButton Class

Inherits: Widget

Interface for widget button handling.

See Also#

  • 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.Get();

	// 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.AddCallback(Gui.CALLBACK_INDEX.CLICKED, OnButtonClicked);

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

WidgetButton Class

Properties

string Text#

The button text label.
set
Sets a button text label.
set value - Button label.

int TextAlign#

Alignment of the button label.
set
Sets alignment of the button label.
set value - One of the GUI_ALIGN_* pre-defined variables.

string Texture#

The path to the button image texture.
set
Sets a button image texture.
set value - Path to a texture file.

bool Toggled#

A value indicating if the toggle button is pressed.
set
Sets a state of the toggle button.
set value - Positive number to press the button, 0 to release it.

bool Toggleable#

A value indicating if the button is a toggle button or a simple one. the default is 0.
set
Sets a value indicating if the button is a toggle button or a simple one.
set value - Positive number to make the button a toggle button, 0 to make it a simple one.

int Background#

A value indicating if a background texture is rendered for the button. the default is 1.
set
Sets a value indicating if a background texture should be rendered for the button. By default, the background texture is always rendered. The default is 1.
set value - Positive number to render a background texture, 0 not to render.

vec4 ButtonColor#

Returns the current color for the button.
set
Sets the color to be used for the button.
set value - Four-component vector specifying the color in the RGBA format.

Members


static 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.

static 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 ) #

Updates a button image.

Arguments

  • Image image - Image to set.

Image GetImage ( ) #

Returns the button image.

Return value

Button image.
Last update: 2021-02-17
Build: ()