简体   繁体   中英

How to solve Identifer Expected problem in C# unity?

Here is my code in which the identifier problem causes.

for (int i = 0; i < buttons.Length; i++)
{
    Text[] = buttons[i].GetComponentsInChildren<Text>();
}  

Unknown identifier: This type of error could mean that Unity does not know the variable that you are referring to and it is expecting an Identifier. This might be due to these reasons:

  • The name of the variable that you are using is incorrect.
  • The variable has not been declared yet.
  • The variable has been declared but outside the scope of the method.

Note: The names of all variables and functions are case-sensitive, just using an incorrect case, will assume that you're referring to another variable.

Try this:

   for (int i = 0; i < buttons.Length; i++)
   {
       Text[] texts = buttons[i].GetComponentsInChildren<Text>();
   }  

You can refer these links link-1 link-2

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM