- Home /
Game temporarily freezes on android
In the beginning of my game, I have it set to fade to black and then load the next scene but, whenever I click, the game freezes for a small amount of time and then goes black completely without a proper transition. Now, I know the fade code is correct because it works perfectly fine running it inside unity.
Here is the code for the thing I was talking about:
using UnityEngine;
using System.Collections;
public class Test : MonoBehaviour {
public int level;
public GUISkin skin;
void Update()
{
if (Input.GetMouseButton(0)){
gameObject.GetComponent<Fadeout>().enabled = true;
Invoke("fade",0.5F);
}
}
void fade()
{
Application.LoadLevel(level);
}
}
I've tried making my own timer, coroutines and involking but, all to the same fate. If you need anymore information to help me solve this issue, please ask.
I'm still looking for help on this one! Community, please don't fail me.
Answer by SkaredCreations · Dec 16, 2014 at 11:31 AM
You would really notice a fading that lasts for half second? You would be really a superman. I suggest you to have a public boolean variable in your Fadeout that is false by default and set it to true in your Fadeout code when the fade ends, finally change Invoke with InvokeRepeating in the code attached to this post and in the "fade" function you would call LoadLevel only if the above variable from Fadeout is true. Also you should enter the Input.GetButton statement only if the Fadeout component is not already enabled, else it could execute the same code more times if you click more than once.
The fade isn't half a second long, that is not how that works. The problem is that, it works fine on windows but, doesn't work very well on android and I'm looking for a fix.
I don't understand how IT can work in Any platform, looking at line 15 your Invoke is calling the function after half second.
Would you like the .apk so I can show you what I'm talking about?
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Soft turn with joystick 0 Answers
How do I get Input.GetKeyDown(KeyCode.Escape) to register? 2 Answers
How can I use WebClient to download files on Android when behind a proxy? 1 Answer
Jittery movement of sprite on device 1 Answer