How to create a dropdown in Unity! In this tutorial we build a simple dropdown menu and get the selected value.


❤️ Subscribe to Oxmond Tutorials. New tutorials every day! Stay tuned!
https://bit.ly/SubscribeOxmondTutorials

Free Assets from the Unity Assets Store:
https://assetstore.unity.com/lists/top-free-packages-13201?aid=1100l4p9k

😷👕 Need a face mask / developer T-shirt? Drop by our shop and get a 20% DISCOUNT on your first purchase by using the discount code OXMONDSALE. Click here:
https://shop.oxmond.com/discount/OXMONDSALE


The Dropdown script:

/*

   .-------.                             .--.    .-------.     .--.            .--.     .--.        
   |       |--.--.--------.-----.-----.--|  |    |_     _|--.--|  |_.-----.----|__|---.-|  |-----.
   |   -   |_   _|        |  _  |     |  _  |      |   | |  |  |   _|  _  |   _|  |  _  |  |__ --|
   |_______|__.__|__|__|__|_____|__|__|_____|      |___| |_____|____|_____|__| |__|___._|__|_____|
   © 2019 OXMOND / www.oxmond.com 

*/

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;

public class DropDown : MonoBehaviour
{

    public TextMeshProUGUI output;

    public void HandleInputData(int val)
    {
        if (val == 0) {
            output.text = "I LOVE MINECRAFT";
        }
        if (val == 1)
        {
            output.text = "I LOVE FORTNITE";
        }
        if (val == 2)
        {
            output.text = "I LOVE CS:GO";
        }
    }  
}