Need threading badly, every time i download a texture using WWW in a coroutine, the whole game still freezes, and i have to download a lot of textures, so the player constantly freeze in place it really sucks, this is the very worst part of my game right now.
It would be great if i coul d put that part of it on a separate thread.
When do you think threading for WebGl will be ready?
I know coroutines are not the same as threading. Coroutines are no good for downloading things while the game is running, it makes the game freeze (it shouldnt, but it does). threads would be better!
Asking for a feature to be threaded in Unity is quite different from this topic, which is about threading in WebGL. Anyway I think the problem may be something you’re doing in your code, since downloading textures with WWW doesn’t cause any freezing in the editor or with WebGL here.
The whole game freeze for a few milli-seconds everytime it downloads a texture, and its downloading a LOT of textures! Here is the code im using, please let me know if you see anything wrong that will cause the freeze, thanks
No it still freeze, I made a new project containing only a cube, and a script to spin the cube while loading a texture form a url using www, and i can easily see the cube stopping while the texture is being loaded. The code doesnt even asign the texture to anything or destroy anything, yet the cube still freeze during loading.
This is exactly whats happening in my game.
Maybe you could post your code that you say doesnt freeze?
Your code is located in the start function, so if there is a freeze you cant tell.
If you want to see the freeze in the editor, simple create a new scene with just a 3D cube, then attach the script below to the cube, then run it, you can see the cube spinning, then it freeze every few seconds right there in the editor.
Please show me how to modify the script so that the cube never freeze.
Thanks!
using UnityEngine;
using System.Collections;
public class SpinCube : MonoBehaviour {
bool busy = false;
Well made demo!
It doesn’t freeze for the whole downloading process, but just for a second or a fraction of second, just before the image appears on the screen.
I get a brief hiccup, which is the texture being uploaded to the GPU once the download is complete; that happens in any kind of build. Although it might be a bit slower with WebGL.