I have a script which is meant to detect the vertical axis on your keyboard to know if it should move the GUI.FocusControl up or down but it won’t work with my arrays.
this is the OnGUI part:
void OnGUI () {
GUI.skin.button.fontSize = 42;
GUI.skin = mySkin;
GUI.color = guiShouldColor;
if (firstSelect)
{
if (Time.time > joyCheckDelay && Input.GetAxisRaw("Vertical") != 0)
{
allOptions = JoyCheck(-Input.GetAxis ("Vertical"), allOptions, firstMax);
joyCheckDelay = Time.time + 0.25f;
}
firScrBol = UpdateScreen(allOptions,firScrBol);
ChangeFocus(firScrStr,firScrBol);
if (Input.GetKeyDown(KeyCode.A))
{
int chosen = 0;
for (int i = 0;i < firScrBol.Length;i++)
{
switch (firScrBol*) {*
-
case true:*
-
if (i == 0)*
-
{*
-
StartCoroutine(Fade("makeSelect"));*
-
}*
-
if (i == 1)*
-
{*
-
StartCoroutine(Fade("joinSelect"));*
-
}*
-
break;*
-
case false:*
-
print ("it would let you join");*
-
break;*
-
}*
-
}*
-
}*
-
GUI.Button(firScrRec[0],firScrStr[0]);*
-
GUI.Button(firScrRec[1],firScrStr[1]);*
-
GUI.Button(firScrRec[2],firScrStr[2]);*
-
GUI.Button(firScrRec[3],firScrStr[3]);*
-
}*
- }*
this is the part which changes the focus:
void ChangeFocus (string[] stringValues,bool[] whichTrue) { - for (int i = 0;i < whichTrue.Length;i++)*
-
{*
-
print (i);*
_ if (whichTrue*)_
_ {_
_ GUI.SetNextControlName(stringValues);
print (“Set It”);
GUI.FocusControl(stringValues);
print (stringValues);
print (“Done”);
if (GUI.GetNameOfFocusedControl() != stringValues)
{
print (“Something is wrong”);
}
}
}
}*
i couldn’t find out what was wrong with it but i even added an error check which will just check if the currently focused control name is the same as the one that i was trying to assign and if it isn’t it will show something is wrong and it will always show it till i get to the lowest possible value.
Edit: in the update function i added a print which will print the current focused gui name and it always comes up empty._