Constructing the name of the variable being accessed
Hi, maybe this is far out and not suppported whatsoever or totaly and it's a newb question... you tell me :)
Is there a way to construct thru script the name of a variable being access?
When iterating, for example, I could have (This does not work...):
 for(int i = 0; i < childCount; i++){
    var MyConstructedVariableName = ("myChild" + i).ToString();
    if(myGameObject.GetComponent<myScript>().MyConstructedVariableName != null){
      DoSomething();
    }
 }
Inspires anyone?
Thanks!
Answer by NoseKills · Jan 03, 2016 at 11:04 AM
You can do that with 'reflection' but i'd recommend you to use a dictionary unless there's something that pevents you from doing that
Your answer
 
 
             Follow this Question
Related Questions
Assigning variables depending on other variables 1 Answer
how to controll a variable of a script from another script 2 Answers
Interchangeable animations in a script? 0 Answers
Basic Enemy follow script for Unity five, desperately needed! 0 Answers
error CS1525: Unexpected symbol `(', expecting `)', `,', `;', `[', or `=' 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                