Is it possible to nest UI drop downs? I can’t seem to find any documentation on this. Maybe I’m searching for the wrong terms. I need to build the first drop down via script, but the nested drop down is a set of options that are set in the editor and do not change. I’d like to place the second as the last item of the first. Can this be done?
I assume you’re talking about UI.Dropdown. I honestly didn’t realize that existed until just now — I’ve been making drop-downs (or pop-ups, as some people call 'em) the old-fashioned way, by just showing/hiding a list of options I create myself. So, when I first read your message, my reaction was, “Well of course you can do that, would couldn’t you?”
But I’m not sure exactly how you’d go about it using UI.Dropdown. You might have to override CreateItem to create a custom item for that one with the submenu.
But if push comes to shove, and it turns out that UI.Dropdown can’t do it for some reason, you can always just forego that and create it all yourself out of more primitive UI elements — it’s not all that hard to do.
HTH,
- Joe
Yep, that’s the what I was referring to. Didn’t realize you could or would roll your own.
This approach might help me with an additional issue I’m having with an input field that I’m using in conjunction with the drop down. Sadly I’m only about a month into Unity and not even considering taking my training wheels off yet. While I kind of get the gist of the concept, I have no clue how to implement that sort of thing. I can get as far as using an image or panel as a background and placing text items as children, but I don’t have a clue how to dynamically build and populate that. Add selection highlight and selecting an item. Nope, don’t have the foggiest idea how to do that or where to start.
I guess I’ll try searching for popups, maybe I’ll find something there. I’ve burnt two days trying to implement a solution for a simple thing, it shouldn’t be so difficult, I could do this this in other environments in about 20 minutes.
So, I guess the answer to the question is no. And if you need to, you have to do it yourself.
I don’t think it helped as much as clarified the direction I must follow. I know this UI system is considered ‘New’, but it’s not that new, and I can’t understand why Unity would implement a drop down UI element without the ability to make a sub-menu item with another drop down as children of the parent item. Can I be the only one needing such functionality? Am I missing something obvious? I’m struggling to understand why Unity made this decision in the development stage, and how others are dealing with the lack of support for this.
I don’t see why you wouldn’t be able to nest it, you can nest everything else in UI land.
The dropdown was added after the UI was released, I’ve also never used it. You could ask on the UI forums. The source for UI is available, so you might be able to modify it yourself.
For a manual dropdown I made this video. The first one is all editor based.
The second one is on a dynamic menu from code.
Thank you Joe and Bored for the responses…
Yeah, I know you can but I’ve not seen an example or even a request for this on the interwebs. I have this vague - hazy view in my head how to do this, but I’m way to new to have the skill set to go about this. ‘The devil is in the details’, quote for someone.
As a beginner, in the last month or so, I’ve taken in so much information, from so many sources, that I now have zero recall of anything. As an example, I was aware of the UI forum, but didn’t even occur to me to go there for help. I’m struggling to go forward in the learning process, but things learned are not remembered and most things are not understood to the degree I need to have to use them properly. Every new thing I learn creates 10 new questions. I can either continue to do research to answer these new questions and get stuck into an endless loop of googling and video watching, or jump into the editor (or mono) and try to figure it out on my own. One keeps me away from Unity completely and the other relies on a basic knowledge set and understanding that I’m attempting to gain. Either way, I don’t seem to be able to make much progress. The ‘do it yourself’ method, may produce results, but allows for bad practices, and improper usage, convoluted and non-maintainable code, and usually little is truly understood from the process. I guess I lack the aptitude for this, which is hard to accept because I’m coming from a background where I did excel in many other environments. I know I can learn this, but I’m still searching for the path that will blend with my way of learning. I would love to sit down with someone for about an hour and over coffee, pick their brain so I can solidify some of the fundamentals that I’m struggling to grasp. I’m stuck in a paradox of, I can’t do until I know, I can’t know until I learn, I can’t learn until I do. The learning curve seems to a vertical line…
Is it worth having a sample scene where each time you learn something you build an example of it in the sample scene, complete with text slabs for notes etc, that you can refer back to as a refresher when you are wanting to start combining or expanding things?
Thank you for replying,
Bored, I watched your videos prior to posting my question. Initially I thought you gave me the answer and that I simply had to disable the button image and I’d have my drop down list. But a properly working drop down (popup) uses different events than your example of buttons. I could be missing something obvious but I just can see how or what to modify to produce what I need from what you provided.
ted, thank you for the suggestion. I’ve kind of wondered how and where to store useful examples snippets from the start. But again, one solution gives birth to many questions. Do I save these scenes in a separate project or with the one I’m working on? How do I ‘cleanup’ a completed project if I keep in the current one? I just see workflow problems with keeping things both internal to a project and external to a project. Confused as always…
I don’t know if I’m stuck in analysis paralysis or what. Things I felt I was starting to understand are shattered by an issue I try to fix. Nothing seems to coalesce. Every new item I add causes issues with what I have previously done. I throw out poorly designed scripts and replace with a different approach only to find down the road that that too was a bad approach. I am doing this all by trial and error to fix problems rather than an intentional correction based on an understanding of the problem. I realize those of you who know and understand how to use Unity properly are struggling to see what my problem is and frankly I don’t know either. I truly don’t feel I’m leaning enough to accomplish anything on my own and it’s not for the lack of trying.
I just have a project called sample scenes. I create new scenes in it as needed & where possible I group the assets for each example into its own asset sub folder. Then when I get stuck I open up a second unity session on another screen, find what I need (hopefully) & either recreate those bits or copy & paste them across. It’s not perfect but it helps with the simple projects I work on.
thanks ted,
Looks like there is no simple way to run another instance of Unity on a Mac. At this stage I really don’t need yet another level of complexity to my life. I recognize the benefits, and a great way to keep a personal library of examples. Currently the only thing I’ve produced is nonfunctional, so I have nothing to save. I’m not ready to burden myself with adding this workflow. I need the ability to produce functional and useable things before I need the ability to save them for future use. A lofty goal for someday that seems like a long time from now.
Un-necro’ing this thread because I was looking up nesting. I’m using TMP_Dropdowns but I realized if you use an event trigger you can check pre-value hover using the transform child index of the menu item
Put an event trigger on the template item
Then throw an Event Trigger on it and run a call from whichever event you want
Void function checking “who are we hovering over”
public void SelectHoverTagEditorPresetSubMenu(Transform _MenuItem) {
Debug.Log("_MenuItem.GetSiblingIndex(): " + _MenuItem.GetSiblingIndex());
if (_MenuItem == _MenuItem.parent.GetChild(7)) {
_MenuItem.GetChild(_MenuItem.childCount -1 ).gameObject.SetActive(true);
_MenuItem.GetChild(_MenuItem.childCount - 1).GetComponent<TMP_Dropdown>().Show();
} else {
_MenuItem.GetChild(_MenuItem.childCount - 1).gameObject.SetActive(false);
_MenuItem.GetChild(_MenuItem.childCount - 1).GetComponent<TMP_Dropdown>().Hide();
}
}
I’d post a screenshot of my final result but I’m messing with the UI format, buzz off