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 

Modern UI Pack

  • Quick Start
  • How To (FAQs)
  • UI Elements
    • Button
    • Charts
    • Context Menu
    • Dropdown
    • Horizontal Selector
    • List View
    • Modal Window
    • Movable Window
    • Notification
    • Progress Bar
    • Slider
    • Switch
    • Tooltip
    • Window Manager
    • Other Elements
  • UI Manager
  • Others & Add-ons
  1. Home
  2. Modern UI Pack
  3. UI Elements
  4. Switch
Updated on August 3, 2022

Modern UI Pack

  • Quick Start
  • How To (FAQs)
  • UI Elements
    • Button
    • Charts
    • Context Menu
    • Dropdown
    • Horizontal Selector
    • List View
    • Modal Window
    • Movable Window
    • Notification
    • Progress Bar
    • Slider
    • Switch
    • Tooltip
    • Window Manager
    • Other Elements
  • UI Manager
  • Others & Add-ons

Switch

Author: admin 248 views

Basically, think of this thing as a different kind of toggle.

Saving

You can save the last selected value by checking the ‘Save Value’ box. Note that every switch should has its own unique ‘Switch Tag’ value in order to save correctly.

Properties

Property Type Function

invokeAtStart

bool

Process switch events at start when enabled.

isOn

bool

Returns/sets the current switch state.

onValueChanged

UnityEvent

Invokes assigned events depending on isOn.

Scripting

				
					using UnityEngine;
using Michsky.MUIP; // MUIP namespace

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

    void YourFunction()
    {
        mySwitch.AnimateSwitch(); // Changing switch state automatically - no updating required
        mySwitch.SetOn(); // Set state to on
        mySwitch.SetOff(); // Set state to off
        mySwitch.isOn = false; // Changing state manually
        mySwitch.UpdateUI(); // Updating UI manually
        mySwitch.onValueChanged.AddListener(TestFunction); // Add dynamic events
    }

    void TestFunction(bool value)
    {
        if (value == true) { Debug.Log("Return true"); }
        else { Debug.Log("Return false"); }
    }
}				
			

How can we help?

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

© 2024 Michsky