Class Button
- Namespace
- UILib.Components
- Assembly
- UILib.dll
A button component.
Buttons can have textures or text on them and handle click events.
public class Button : UIComponent
- Inheritance
-
Button
- Derived
- Inherited Members
Constructors
Button()
Initializes a blank button.
public Button()
Button(string, int)
Initializes a button with the specified text.
public Button(string text, int fontSize)
Parameters
Button(Texture2D)
Initializes a button with a texture.
public Button(Texture2D texture)
Parameters
textureTexture2DThe texture to add to this button
Properties
background
The button's background.
public Image background { get; }
Property Value
button
The underlying Unity Button.
public Button button { get; }
Property Value
- Button
image
The image attached to this button, if any.
public Image image { get; }
Property Value
label
The label attached to this button, if any.
public Label label { get; }
Property Value
onClick
Invokes listeners when this button is clicked.
public override UnityEvent onClick { get; }
Property Value
- UnityEvent
playSound
Whether this button will play the navigation sound when clicked.
public bool playSound { get; }
Property Value
Methods
SetBackground(Texture2D)
Allows changing the background image of the button.
public void SetBackground(Texture2D texture)
Parameters
textureTexture2DThe texture to use instead
SetPlaySound(bool)
Sets whether this button should play the navigation sound.
public void SetPlaySound(bool playSound)
Parameters
playSoundboolWhether this button should play a sound
SetText(string)
Sets the text on this button.
public void SetText(string text)
Parameters
textstringThe text to set
SetTexture(Texture2D)
Sets the texture on this button.
public void SetTexture(Texture2D texture)
Parameters
textureTexture2D
SetThisTheme(Theme)
Allows setting the theme of this button.
This handles setting the theme specifically for this component, not its children. It's protected to allow overriding if you were to create a subclass.
In most cases, you'd probably want to use SetTheme(Theme) instead.
protected override void SetThisTheme(Theme theme)
Parameters
themeThemeThe theme to apply