logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class UnityUiToggleComponent

    Unity UI toggle component that provides toggle and submit functionality for boolean value selection.
    Combines toggle behavior with submittable actions to create interactive UI elements for binary choices.
    Implements both IUiToggleable and IUiSubmittable interfaces for comprehensive boolean input handling within the Unity UI system.

    Inheritance
    object
    UnityUiComponent
    UnityUiInteractableComponent
    UnityUiToggleComponent
    Implements
    IUiInteractable
    IUiComponent
    IUiToggleable
    IComponent
    IFoundationSettings
    IUiSubmittable
    Inherited Members
    UnityUiInteractableComponent._contentWrapperGameObject
    UnityUiInteractableComponent._labelGameObject
    UnityUiInteractableComponent._highlightGameObject
    UnityUiInteractableComponent._valueGameObject
    UnityUiInteractableComponent._mainButtonGameObject
    UnityUiInteractableComponent._optionValueUiComponentType
    UnityUiInteractableComponent._decorationsCoroutine
    UnityUiInteractableComponent._buttons
    UnityUiInteractableComponent._isDragging
    UnityUiInteractableComponent._wantsHighlightVisible
    UnityUiInteractableComponent._widthLocked
    UnityUiInteractableComponent.SetupDecorations(bool)
    UnityUiInteractableComponent.AdaptHighlightWidthToText(Image, TMP_Text, RectTransform, float, bool, bool, GameObject)
    UnityUiInteractableComponent.GetHighlightTargetWidth(Image, TMP_Text, RectTransform, float, bool, bool, GameObject)
    UnityUiInteractableComponent.RelocateHighlightImage(Image, TMP_Text, RectTransform, RectTransform)
    UnityUiInteractableComponent.GetHighlightImage(Image, TMP_Text, RectTransform)
    UnityUiInteractableComponent.SetWidthLocked(bool)
    UnityUiInteractableComponent.IsWidthLocked()
    UnityUiInteractableComponent.SetAutoDecorationsEnabled(bool)
    UnityUiInteractableComponent.GetDecorationsPassVersion()
    UnityUiInteractableComponent.RunDecorations(bool)
    UnityUiInteractableComponent.CalculateLogicalWidth()
    UnityUiInteractableComponent.Awake()
    UnityUiInteractableComponent.OnDisable()
    UnityUiInteractableComponent.RefreshLayoutAfterTextChange()
    UnityUiInteractableComponent.IncrementValue()
    UnityUiInteractableComponent.DecrementValue()
    UnityUiInteractableComponent.SetIndex(int)
    UnityUiInteractableComponent.GetIndex()
    UnityUiInteractableComponent.SetIsDragging(bool)
    UnityUiInteractableComponent.GetIsDragging()
    UnityUiInteractableComponent.OnDraggingStart()
    UnityUiInteractableComponent.OnDraggingEnd()
    UnityUiInteractableComponent.Focus()
    UnityUiInteractableComponent.Blur()
    UnityUiInteractableComponent.SelectNextComponent()
    UnityUiInteractableComponent.SelectPreviousComponent()
    UnityUiInteractableComponent.SelectComponentById(string)
    UnityUiInteractableComponent.SetFocus(bool)
    UnityUiInteractableComponent.Initialize(IUiComponentParameters, IUiComponentActions, ILogService)
    UnityUiInteractableComponent.SetFocusAnimation()
    UnityUiInteractableComponent.SetDeselectedAnimation()
    UnityUiInteractableComponent.Cancel()
    UnityUiInteractableComponent.MapTMPAlignment(UiComponentAlignmentType)
    UnityUiInteractableComponent.InitializeLabel(string)
    UnityUiInteractableComponent.InitializeVisualElement()
    UnityUiInteractableComponent.InitializeVisualElement(UiComponentInteractionType, UiComponentAlignmentType, float, string)
    UnityUiInteractableComponent.InitializeHighlight()
    UnityUiInteractableComponent.AlignElements(UiComponentInteractionType, UiComponentAlignmentType)
    UnityUiInteractableComponent.SetHighlightAlignment(UiComponentAlignmentType)
    UnityUiInteractableComponent.SetLabelAlignment(UiComponentAlignmentType)
    UnityUiInteractableComponent.HandleCenterAlignment(TMP_Text)
    UnityUiInteractableComponent.FlipHorizontally(GameObject)
    UnityUiInteractableComponent.SetValueAlignment(UiComponentInteractionType, UiComponentAlignmentType)
    UnityUiInteractableComponent.InitializeMirroring(UiComponentAlignmentType)
    UnityUiInteractableComponent.SetButtonAlignment(UiComponentAlignmentType)
    UnityUiInteractableComponent.SetElementPosition(float, UiComponentAlignmentType)
    UnityUiInteractableComponent.GetContentWrapperGameObject()
    UnityUiInteractableComponent.SetContentWrapperGameObject(GameObject)
    UnityUiInteractableComponent.GetLabelElement()
    UnityUiInteractableComponent.GetLabelGameObject()
    UnityUiInteractableComponent.SetLabelGameObject(GameObject)
    UnityUiInteractableComponent.SetLabelElement(IFoundationViewElement)
    UnityUiInteractableComponent.GetMainButtonElement()
    UnityUiInteractableComponent.SetMainButtonGameObject(GameObject)
    UnityUiInteractableComponent.GetMainButtonGameObject()
    UnityUiInteractableComponent.SetMainButtonElement(IFoundationViewElement)
    UnityUiInteractableComponent.SetHighlightGameObject(GameObject)
    UnityUiInteractableComponent.GetHighlightElement()
    UnityUiInteractableComponent.GetHighlightGameObject()
    UnityUiInteractableComponent.SetHighlightElement(IFoundationViewElement)
    UnityUiInteractableComponent.GetValueElement()
    UnityUiInteractableComponent.SetValueGameObject(GameObject)
    UnityUiInteractableComponent.GetValueGameObject()
    UnityUiInteractableComponent.SetValueElement(IFoundationViewElement)
    UnityUiInteractableComponent.SetLabelText(string)
    UnityUiInteractableComponent.SetValueText(string)
    UnityUiInteractableComponent.GetButtonElements(bool)
    UnityUiInteractableComponent.GetButtonGameObjects(bool)
    UnityUiInteractableComponent.SetButtonElements(List<IFoundationViewElement>)
    UnityUiInteractableComponent.GetUiComponentInteractionType()
    UnityUiInteractableComponent.SetUiComponentInteractionType(UiComponentInteractionType)
    UnityUiInteractableComponent.InitializeButtons()
    UnityUiInteractableComponent._decorationsInitialized
    UnityUiInteractableComponent.InteractableParameters
    UnityUiInteractableComponent.InteractableActions
    UnityUiInteractableComponent.DecorationsReady
    UnityUiComponent._animators
    UnityUiComponent.UpdateUiElement<T>(Action<T>, IFoundationViewElement)
    Namespace: Serenity.Ui.Infrastructure.Components
    Assembly: Serenity.UnityUi.Infrastructure.dll
    Syntax
    public class UnityUiToggleComponent : UnityUiInteractableComponent, IUiInteractable, IUiComponent, IUiToggleable, IComponent, IFoundationSettings, IUiSubmittable

    Constructors

    UnityUiToggleComponent()

    Initializes a new instance of the UnityUiToggleComponent.
    Sets up the component type as a toggle interaction for proper UI behavior and event handling.

    Declaration
    public UnityUiToggleComponent()

    Properties

    SubmittableActions

    Gets or sets the submittable actions interface for submission event handling.
    Manages callbacks for submission events when the toggle is activated or confirmed.

    Declaration
    public IUiSubmittableActions SubmittableActions { get; set; }
    Property Value
    Type Description
    IUiSubmittableActions

    The submittable actions interface

    ToggleableActions

    Gets or sets the toggleable actions interface for toggle event handling.
    Manages callbacks for toggle state changes and boolean value interactions.

    Declaration
    public IUiToggleableActions ToggleableActions { get; set; }
    Property Value
    Type Description
    IUiToggleableActions

    The toggleable actions interface

    ToggleableParameters

    Gets or sets the toggleable parameters interface for toggle configuration.
    Provides access to the current boolean value and toggle-specific settings.

    Declaration
    public IUiToggleableParameters ToggleableParameters { get; set; }
    Property Value
    Type Description
    IUiToggleableParameters

    The toggleable parameters interface

    Value

    Gets or sets the boolean value of the toggle component.
    Provides direct access to the toggle state with automatic parameter synchronization.

    Declaration
    public bool Value { get; set; }
    Property Value
    Type Description
    bool

    The current boolean value

    Methods

    OnEnable()

    Unity lifecycle method called when the component is enabled.
    Initializes the toggle value from parameters and calls base initialization for proper component setup.

    Declaration
    public override void OnEnable()
    Overrides
    UnityUiInteractableComponent.OnEnable()

    SetValue(bool)

    Sets the toggle value directly with a boolean.
    Updates both the component parameters and the Unity Toggle UI element without triggering change events.
    Uses Unity's SetIsOnWithoutNotify method to prevent recursive event triggering.

    Declaration
    public void SetValue(bool newValue)
    Parameters
    Type Name Description
    bool newValue

    The boolean value to set for the toggle

    SetValue(string)

    Sets the toggle value from a string representation.
    Parses the string value as a boolean and applies it to the toggle component with validation.
    Supports common boolean string representations for flexible value setting.

    Declaration
    public override void SetValue(string value)
    Parameters
    Type Name Description
    string value

    The string value to parse and set ("true" or "false")

    Overrides
    UnityUiInteractableComponent.SetValue(string)
    Exceptions
    Type Condition
    ArgumentException

    Thrown when the string cannot be parsed as a boolean value

    Submit()

    Handles submission actions by toggling the value and triggering submission callbacks.
    Combines toggle functionality with submission behavior for comprehensive user interaction handling.
    Calls base submit functionality and invokes both toggle and submit action callbacks.

    Declaration
    public override void Submit()
    Overrides
    UnityUiInteractableComponent.Submit()

    Toggle()

    Toggles the current boolean value and triggers toggle action callbacks.
    Flips the current state from true to false or vice versa and invokes toggle event handlers.
    Provides the core toggle functionality for user interactions.

    Declaration
    public void Toggle()

    Implements

    IUiInteractable
    IUiComponent
    IUiToggleable
    IComponent
    IFoundationSettings
    IUiSubmittable
    In this article
    © 2026 Serenity. All Rights Reserved