Michsky – Docs Michsky – Docs
  • Home
  • Documentation
    • Reach UI
    • DreamOS
    • Modern UI Pack
    • Motion Titles Pack
    • Dark UI
    • Loading Screen Studio
  • Contact
Michsky – Docs Michsky – Docs
Michsky – Docs
  • Home
  • Documentation
    • Reach UI
    • DreamOS
    • Modern UI Pack
    • Motion Titles Pack
    • Dark UI
    • Loading Screen Studio
  • Contact

Reach UI

  • Quick Start
  • Animations
  • Controller & Input
    • Controller Manager
    • Controller Presets
    • Hotkey Event
    • UI Navigation
  • Handlers & Managers
    • Achievements
    • Audio
    • Chapters
    • Credits
    • Effects
    • In-Game
  • Localization
    • Getting Started
    • Localization Settings
    • Localization Manager
    • Localized Object
  • UI Elements
    • Button
    • Dropdown
    • Modal Window
    • Panel Manager
    • Progress Bar
    • Selectors
    • Slider
    • Switch
    • Widgets
    • Others
  • UI Manager
  • Others & Add-ons
  1. Home
  2. Docs
  3. Reach UI
  4. UI Elements
  5. Switch
Updated on January 2, 2023

Reach UI

  • Quick Start
  • Animations
  • Controller & Input
    • Controller Manager
    • Controller Presets
    • Hotkey Event
    • UI Navigation
  • Handlers & Managers
    • Achievements
    • Audio
    • Chapters
    • Credits
    • Effects
    • In-Game
  • Localization
    • Getting Started
    • Localization Settings
    • Localization Manager
    • Localized Object
  • UI Elements
    • Button
    • Dropdown
    • Modal Window
    • Panel Manager
    • Progress Bar
    • Selectors
    • Slider
    • Switch
    • Widgets
    • Others
  • UI Manager
  • Others & Add-ons

Switch

Author: admin 39 views

Workflow

Basically, you can think of this thing as a re-skinned toggle.

Saving Data

You can save the switch value by enabling the ‘Save Value’ option. Note that each switch must have its own unique ‘Save Key’ value. Otherwise, there may be conflict(s) between the switches.

Scripting

				
					using UnityEngine;
using Michsky.UI.Reach; // Reach UI namespace

public class SampleClass : MonoBehaviour
{
    [SerializeField] private SwitchManager mySwitch;

    void Start()
    {
        // Set new value
        mySwitch.SetOff();
        mySwitch.SetOn();

        // Change settings
        mySwitch.isInteractable = false;
        mySwitch.useSounds = true;

        // Apply the changes and update the UI
        mySwitch.UpdateUI();

        // Add progress bar events
        mySwitch.onValueChanged.AddListener(TestFunctionDynamic);
        mySwitch.onEvents.AddListener(TestFunction);
        mySwitch.offEvents.AddListener(TestFunction);
    }

    void TestFunctionDynamic(bool value)
    {
        Debug.Log("Current value: " + value.ToString());
    }

    void TestFunction()
    {
        Debug.Log("Test function");
    }
}				
			

How can we help?

A premium WordPress theme with an integrated Knowledge Base,
providing 24/7 community-based support.

Content

© 2023 Michsky