Home > other >  Unity how to acquire the DropDown can text
Unity how to acquire the DropDown can text

Time:09-26

I get DropDown can text, must first obtain DropDown can object,
My code is as follows:
Public Dropdown can av;
Public GameObject go;
Public void the Start ()
{
//-- -- -- -- -- -- -- -- -- -- - (1)
Go=GameObject. Find (" AngelView ");
Av=go. GetComponent (a);
The Debug Log (av);
}
Go to print out of it is not Null Null values, is a DropDown can but I think GetComponent, av, is empty,
I tried for Setting the Menu first, then get GetComponent, av is as empty,
The following is my Hierarchy

The Setting Menu is the most began to Create the Empty of DropDown can and AngelView are DropDown can object, but I just want AngelView,
Ask how to solve this problem

CodePudding user response:

Capture a full screen to see it

CodePudding user response:

Av=go. GetComponent (a); You just won a Dropdown can class, in class and see what interface can be called, directly print to print the class itself is generally

CodePudding user response:

GameObject. GetComponent (). ItemText

CodePudding user response:

Dropdown can Dropdown can=FindObjectOfType (a);
If (dropdown can!=null)
{
String STR=dropdown can. ItemText. Text;
}
  • Related