- Home /
Coroutine not working properly on Android (C#)
I'm just started learning Unity for android (c#) and bumped to strange behavior. I have cod for downloading image from url which works as normally in editor. Code like this:
void Start ()
> {
> //do smthing
> StartCoroutine (LoadImg());
> }
>
> IEnumerator LoadImg()
> {
> string url="imageUrl";
> WWW www = new WWW (url);
> yield return www;
> myMat.mainTexture = www.texture;
> }
It successfully change texture of pre-created plane in editor. But on Android it do nothing. The only way that made it work on my Android device is this:
private bool ready;
void Start ()
{
//do smthing
ready = false;
StartCoroutine (LoadImg());
}
void Update()
{
if (ready)
myText.text = "READY!";
else {
myText.text = "NOT READY!";
StartCoroutine(LoadMap());
}
}
IEnumerator LoadImg()
{
ready=true;
string url="imageUrl";
WWW www = new WWW (url);
yield return www;
myMat.mainTexture = www.texture;
}
myText is just GUIText. Any ideas what is going on?
Comment
Your answer
Follow this Question
Related Questions
Problem with animation and void fixedupdate() 1 Answer
Android / iphone - Questions? 1 Answer
Is there a yield WaitForSeconds type code for the update? 2 Answers
[ANSWERED]Move object without Update or coroutine 2 Answers
Installed Android SDK, Java Dev Kit, Unity 4.6.2 - why does Unity crash? 1 Answer