Class Toggle
- Namespace
- UILib.Components
- Assembly
- UILib.dll
A component which is like a Button, but can be toggled on or off.
Also displays a checkmark indicating its current state.
public class Toggle : UIComponent
- Inheritance
-
Toggle
- Inherited Members
Constructors
Toggle(bool)
Initializes this toggle.
public Toggle(bool value = false)
Parameters
valueboolThe default value
Properties
background
The background of the toggle.
public Image background { get; }
Property Value
offImage
The image which displays when the toggle is off.
public Image offImage { get; }
Property Value
onImage
The image which displays when the toggle is on.
public Image onImage { get; }
Property Value
onValueChanged
Invokes listeners with the current value stored in the toggle whenever it's updated.
public ValueEvent<bool> onValueChanged { get; }
Property Value
playSound
Whether this toggle will play the navigation sound when clicked.
public bool playSound { get; }
Property Value
toggle
The underlying Unity Toggle.
public Toggle toggle { get; }
Property Value
- Toggle
value
The current value of the toggle.
public bool value { get; }
Property Value
Methods
SetOffImage(Image)
Sets the image to display in the "off" state.
public void SetOffImage(Image offImage)
Parameters
offImageImage
SetOnImage(Image)
Sets the image to display in the "on" state.
public void SetOnImage(Image onImage)
Parameters
onImageImage
SetPlaySound(bool)
Sets whether this toggle should play the navigation sound.
public void SetPlaySound(bool playSound)
Parameters
playSoundboolWhether this toggle should play a sound
SetThisTheme(Theme)
Allows setting the theme of this toggle.
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
SetValue(bool)
Sets the current value of this toggle.
public void SetValue(bool value)
Parameters
valuebool