Unigine.WidgetButton Class
Inherits from: | 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.
/* .. */
// 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 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.
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 ) #
Updates a button image.Arguments
- Image image - Image to set.
Image GetImage ( ) #
Returns the button image.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:
2022-03-10
Help improve this article
Was this article helpful?
(or select a word/phrase and press Ctrl+Enter)