- Home /
Android build misbehaving.
Sorry about the vague title, but I've got no idea how to explain the issue briefly. I'm having some really weird issues in Unity 5. The program is essentially a comic book app. When the user presses the screen, the next thing happens, whether that is a new panel transitioning in or part of the panel animating. It's super simple stuff - or should be at least. Everything works flawlessly in the editor, and in the standalone application, and in the web player. When I build it for Android there are some strange issues - the major one being that the first panel doesn't slide in until you touch the screen - at which point the panel slides in and the first panel animation happens. This isn't what should happen - when it's running on anything else the first panel comes in automatically and the first animation doesn't happen until you touch the screen (or press space).
Thanks in advance!
Here is the code:
void Update ()
{
GetInput ();
foreach (GameObject panel in panels)
{
Panel pScript = panel.GetComponent<Panel> (); // Get the panel script, which allows me to use public variables and functions
if (pScript.panelNumber == activePanel && panel.activeSelf) // if the panel is active
{
if (!pScript.transitioning) // if the panel is not mid-transition
{
panel.SetActive(true); // activate the panel
pScript.TransitionIn(); // transition in
}
if (sequenceNo != -1 && sequenceNo < pScript.numSequences) // if the sequence number is not -1 (panel transition) and is in range
pScript.ActivateSequence(sequenceNo); // activate the correct animation
if (sequenceNo >= pScript.numSequences) // if the sequence number is greater than the amount of animations in this panel
{
sequenceNo = -1; // reset the sequence number
++activePanel; // move to the next panel
pScript.ResetLerp (); // reset lerp variables (otherwise the animation doesn't play)
pScript.TransitionOut (); // move the panel out of view
}
}
if ((pScript.panelNumber == activePanel-1) && !pScript.transitioning)
panel.SetActive(false); // if the panel is the last used panel and it is finished transitioning, deactivate it
}
}
void GetInput ()
{
if (Input.GetKey (KeyCode.Escape)) // 'Back' key on Android
Application.Quit (); // Quit the application
if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer || Application.platform == RuntimePlatform.WP8Player)
{ // if the platform requires touch input
if (Input.GetTouch (0).phase == TouchPhase.Began) // as soon as a touch is registered
++sequenceNo; // increment the sequence
} else {
if (Input.GetKeyDown (KeyCode.Space)) // if the platform doesn't have touch input
++sequenceNo; // increment the sequence
}
}
[edit: added comments to better explain what's going on]
[Second edit] Escape now works, no idea why. All I did was load and rebuild the project today! However, the other issues are still there, so I've changed the question.
Answer by FlutterCZ · Mar 31, 2015 at 03:26 PM
Not sure, but try to put
if (Input.GetKey (KeyCode.Escape))
Application.Quit ();
into the Update function.