- Home /
Is there anyone who knows how to make a dropdown menu in unity editor with UIelements
I'm a intermediate unity user and I'm trying to be familiar with the UIelements in the unity editor but it seems like there's been no real tutorials about UIelements on youtube yet. Now I can make boxes, texts, images, buttons with UIelements but I just can't figure out how to make dropdown menus, when I read the unity mannual and documentation I can hardly understand anything. If there's someone who knows about UIelements, please answer or make a video tutorials if you can. Thanks in advance!
Answer by naviln · Nov 04, 2019 at 05:51 AM
Hi buddy,
You need a template linked to the UI dropdown. Here is a vid on youtube i made for ya: https://youtu.be/zWYThXK5_WM
I've attached a sample scene with a dropdown here for you: https://drive.google.com/drive/folders/13VWFwNWVFUiaOaQavjCWX9y0xUxgjY7h?usp=sharing (download the testdropdown.unity scene file)
See if that helps you? (It's a very crude example, with no custom scripting to do things, you'll have to add your own on value changed function and link it), but shows you how the gameobject needs to be setup)
Note - I am using TMP Dropdown (Text Mesh Pro), so import that to your project (TMP Essentials).
Answer by su59hekusai · Jan 02, 2020 at 09:08 AM
Is it like this?
By the way, put this file under the folder named Editor.
using UnityEditor;
using UnityEngine;
using UnityEngine.UIElements;
using UnityEditor.UIElements;
public class ExampleUIElements : EditorWindow
{
enum ExampleEnum
{
Foo,
Bar,
Buz
}
[MenuItem("Window/UIElements/ExampleUIElements")]
public static void ShowExample()
{
ExampleUIElements wnd = GetWindow<ExampleUIElements>();
}
public void OnEnable()
{
VisualElement root = rootVisualElement;
root.Add(new EnumField("Label", ExampleEnum.Bar));
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612214319im_/https://answers.unity.com/themes/thub/images/avi.jpg)