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. Dropdown
Updated on May 21, 2024

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

Dropdown

Author: admin 287 views

There are 2 types of dropdown with 3 animation styles. It’s pretty advanced compared to the native dropdown, but don’t worry, it’s easy to use!

Items

You can add dropdown items to this list. If you want to change the item appearance, you can select the ‘Item Prefab’ object (available in the resources tab) and start editing the prefab! It is possible to create multiple presets and assign them differently to each dropdown objects.

Saving

You can save the last selected value by checking this box. Note that every selector should has its own unique Dropdown Tag value.

Properties

Property Type Function
enableTrigger
bool

When enabled, clicking outside closes the dropdown.

setHighPriority
bool

Gets the highest hierarchy sorting within its parent.

isListItem
bool

Changes the dropdown parent to listParent on click.

isOn
bool

Returns the dropdown animation state.

selectedItemIndex
int

Returns the selected dropdown item index.

items
List (CustomDropdown.Item)

Stores all dropdown item data and events.

dropdownEvent
UnityEvent

Process dynamic events on item select.

Scripting

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

public class SampleClass : MonoBehaviour
{
    public CustomDropdown myDropdown; // Your dropdown variable

    void YourFunction()
    {
        // Creating a new item
        myDropdown.CreateNewItem("Item Title", spriteIcon, true);

        // Creating items within a loop
        for (int i = 0; i < yourIndexOrVariable; ++i)
        {
            // Use false when using this in a loop
            myDropdown.CreateNewItem("Item Title", spriteIcon, false);
        }

        // Initialize the new items
        myDropdown.SetupDropdown();

        // Add int32 (dynamic) events
        myDropdown.onValueChanged.AddListener(TestFunction);

        myDropdown.ChangeDropdownInfo(3); // Changing index & updating UI
        myDropdown.RemoveItem("Item Title"); // Delete a specific item
        myDropdown.Animate(); // Animate dropdown
    }

    void TestFunction(int value)
    {
        Debug.Log("Changed index to: " + value.ToString());
    }
}				
			

FYI: You can either use item event or dynamic event. Dynamic Event (onValueChanged) works just like the native dropdown (int32).

How can we help?

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

© 2024 Michsky