In the script, I have a changeable dropdown, where I need to know which element has chosen the user, but if I do it using DropDown.Value, then when you change the dropdown, and I only get the number of the selected item. And here you need to get the text of the element. Is it possible to do it somehow?
code is not particularly required, but here if you need
using system.collections.generic;
using unityengine;
using unityengine.ui;
using unityengine.eventsystems;
using unityengine.scenemanagement;
Public Class Dropdown: Monobehaviour, iPointerDownHandler
{
Public Dropdown DD1;
Public Dropdown DD2;
Public Guistyle MyStyle;
int scrap_count;
Private Void Start ()
{
scrap_count = weaponknowfuckingid.scrap_count;
}
Public Void OnpoINTERDOWN (PointereventData EventData)
{
Weaponknowfuckingid.idfor1weapon = dd1.value;
Weaponknowfuckingid.idfor2weapon = dd2.value;
Scenemanager.loadscene ("samplescene", loadscenemode.single);
}
Private void ongui ()
{
Gui.Box (NEW RECT (20, 0, 1000, 1000), "SCRAP:" + scrap_count, mystyle);
}
}
WEAPONKNOWFUCKINGID simply contains variables with variables and selected guns
Answer 1, Authority 100%
DropDown class instance has a .Options it gives access To all options. At your index, you can actually obtain the desired item and pull out the text from it.
Answer 2
string s = getcomponent & lt; dropdown & gt; (). Options [GetComponent & LT; Dropdown & GT; (). Value] .text;
Debug.log (s);
Supplement @ m.green .