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. Button
Updated on December 11, 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

Button

Author: admin 226 views

MUIP buttons support multiple event types, auto-fitting, and a dynamic content manager. If you want to manage the content manually, you can enable ‘Use Custom Content’ using the manager settings.

Properties

Property Type Function

buttonText

string

Defines the text shown on the button.

buttonIcon

Sprite

Defines the icon shown on the button.

onClick

UnityEvent

Process events on button click.

onDoubleClick

UnityEvent

Process events on double button click.

onHover

UnityEvent

Process events on button hover.

clickSound

AudioClip

Audio clip that plays on button click.

hoverSound

AudioClip

Audio clip that plays on button hover.

useCustomContent

bool

Bypasses content properties (e.g. buttonText) when enabled.

Scripting

				
					using UnityEngine;
using Michsky.MUIP;

public class SampleClass : MonoBehaviour
{
    [SerializeField] private ButtonManager myButton;
    [SerializeField] private Sprite buttonIcon;

    void YourFunction()
    {
        // Updating button content
        myButton.SetText("New Text");
        myButton.SetIcon(buttonIcon);
        
        // Set button interactability
        myButton.Interactable(false);
        myButton.Interactable(true);

        // Enable or disable options
        myButton.useRipple = true;
        myButton.enableButtonSounds = true;
        myButton.useClickSound = true;
        myButton.useHoverSound = true;
        myButton.useCustomContent = false;

        // Add events
        myButton.onClick.AddListener(TestFunction);
        myButton.onDoubleClick.AddListener(TestFunction);
        myButton.onHover.AddListener(TestFunction);
        myButton.onLeave.AddListener(TestFunction);
    }

    void TestFunction()
    {
        Debug.Log("Event test");
    }
}
				
			

Scripting (v5.4 or older)

				
					using Michsky.UI.ModernUIPack; // namespace

public ButtonManager myButton; // There are several button mangers, such as ButtonManagerWithIcon

void YourFunction()
{
   // Updating button content
   myButton.buttonText = "My New Text";
   myButton.buttonIcon = SpriteVar;
   myButton.UpdateUI();
  
   // Enable or disable options
   myButton.useRipple = true;
   myButton.enableButtonSounds = true;
   myButton.useClickSound = true;
   myButton.useHoverSound = true;
   myButton.useCustomContent = false;
}				
			

How can we help?

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

© 2024 Michsky