is it ok to use SWITCH-CASE like this or should I use rather if-else?
And here goes the most important question: which is more resource efficient?
Meaning which uses up less memory?
My script works withou the Input.anyKeyDown condition, but it doesn’t work with it…why is that?
void KeyboardControl()
{
if(Input.GetKeyDown (KeyCode.R))
{
for(int i = 0; i<playerClonesHolder.transform.childCount; i++)
{
playerClonesHolder.transform.GetChild(i).FindChild ("dmgCube").GetComponent<DmgCube_scr>().ChargeStaff();
}
}
if(Input.anyKeyDown)
{
switch(Input.inputString)
{
case "1":
Debug.Log ("1 pressed");
break;
case "2":
Debug.Log ("2 pressed");
break;
case "3":
Debug.Log ("3 pressed");
break;
case "4":
Debug.Log ("4 pressed");
break;
case "5":
Debug.Log ("5 pressed");
break;
case "6":
Debug.Log ("6 pressed");
break;
case "7":
Debug.Log ("7 pressed");
break;
case "8":
Debug.Log ("8 pressed");
break;
case "9":
Debug.Log ("9 pressed");
break;
case "0":
Debug.Log ("0 pressed");
break;
default:
Debug.Log ("this is not a valid key");
break;
}
}
}