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

Hex UI

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

Hex UI

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

Switch

Author: admin 31 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.Hex; // 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.

© 2024 Michsky