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 :slight_smile:

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!

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