I’m working in unity 2021.3.9f1 and want to grab the text value from a TMP dropdown list, and pass it into a string variable.
I want to do that so I can allow users to set their own dropdown list items. I also use the list items to set section headings in a panel. (Plus my functioning graph isn’t exactly streamlined.)
I’ve found a c# code snippet, but I can’t find the right nodes to convert it to visual scripting. I"m avoiding c# as much as possible.
I’ve tried a variety of nodes, as you’ll see from the screenshots. (Pic one is all the nodes - pic 2 is zoomed in to show detail.) The transform node I’m using is to try and grab the string from the dropdown label child object.
So this might not be the best solution, but what I’ve done is add a tag to the label child object of the dropdown, find that object, and use text mesh pro ugui to pull the text from it.
One error in what I’d tried with earlier exploring was to look for text mesh pro nodes rather than text mesh pro ugui.
You’ll quickly run into performance issues with Find methods in OnUpdate. Any kind of Find is slow already, performing that every frame quickly compounds the issue. It would be better to cache the object you’re looking for in an Object variable manually, or use Find in OnEnable or OnStart.
Finding the object by loose string names also keeps your project architecture fragile - if you rename the object later or remove it completely, the logic breaks. Variable use would aid in keeping the project manageable long term.
Ok well I still haven’t been able to add TMP_Text nodes, but I added Text Mesh Pro UGUI as a type in settings, then was able to pull a string directly from the dropdown caption text as in the pic: