Hello everyone.
I’m learning C# and i have a question.
i have 4 public variable
public int _nbLeft;
public int _nbRight;
public int _nbBack;
public int _nbForward;
Basically i would like to create 4 button left if nbLeft = 4, 3 button right if nbRight = 3…
So my idea, instead of doing 4 for to do something close to the object like in Javascript?
like :
var buttons= {};
buttons._nbLeft= 1;
buttons._nbRight= 2;
buttons._nbBack= 2;
buttons._nbForward= 2;
for(var key in buttons){
createButton(key,nb);
}
-----------------------------------
this will give me :
createButton = function(key,nb){
switch(_key){
case _nbLeft:
// do button left...
break;
etc...
}
But i really don’t know in unity, the List can’t take an index and a key, the simple array is out of context…
Well, i don’t know ^^
Can’t someone show me a way to do it correctly.
thx
P.S sorry for the tag… but it was one suggested… i can’t write C# cause apparently i create it…