Table of Contents

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

value bool

The default value

Properties

background

The background of the toggle.

public Image background { get; }

Property Value

Image

offImage

The image which displays when the toggle is off.

public Image offImage { get; }

Property Value

Image

onImage

The image which displays when the toggle is on.

public Image onImage { get; }

Property Value

Image

onValueChanged

Invokes listeners with the current value stored in the toggle whenever it's updated.

public ValueEvent<bool> onValueChanged { get; }

Property Value

ValueEvent<bool>

playSound

Whether this toggle will play the navigation sound when clicked.

public bool playSound { get; }

Property Value

bool

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

bool

Methods

SetOffImage(Image)

Sets the image to display in the "off" state.

public void SetOffImage(Image offImage)

Parameters

offImage Image

SetOnImage(Image)

Sets the image to display in the "on" state.

public void SetOnImage(Image onImage)

Parameters

onImage Image

SetPlaySound(bool)

Sets whether this toggle should play the navigation sound.

public void SetPlaySound(bool playSound)

Parameters

playSound bool

Whether 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

theme Theme

The theme to apply

SetValue(bool)

Sets the current value of this toggle.

public void SetValue(bool value)

Parameters

value bool