I found a strange thing while testing my game on Android. If I have 2 Scripts with OnGui like this:
private void OnGUI()
{
if (!UIManager.InfoIsShown)
{
if (GUI.Button(new Rect(0, Screen.height-InfoLength, InfoLength, InfoLength), InfoTexture, new GUIStyle()))
{
UIManager.InfoIsShown = true;
}
}
}
and the second one
private void OnGUI()
{
//scale with screencenter as center
GUIUtility.ScaleAroundPivot(new Vector3(scale, scale), position);
// If start is pressed, activate all scripts to start the game.
if (!UIManager.InfoIsShown)
{
if (GUI.Button(button, ButtonTexture, new GUIStyle()))
{
InfoButton.SetActive(false);
}
}
The second one works, the first one doesn’t. In the Editor and in the Webdeployment both buttons work.
What’s the problem? Can’t I use multiple OnGui on an Android device? Both of them are shown on the display!
Edit:
What does “doesn’t work” mean? Do you see the two buttons? If you see them, you can’t click them? …
Both of them are displayed. When pressing the second one the code runs. When pressing the first one nothing happens.