I googled my way through lots of questions all day but I didn't seem to find an answer fitting my problem, so I hope somebody can help me.
I want to display several image streams in a Unity scene. I have several GameObjects with the loading-script attached, e.g.
GameObject1 with script Loader.cs (calls coroutine in Start)
GameObject2 with script Loader.cs (calls coroutine in Start)
GameObject3 with script Loader.cs (calls coroutine in Start)
and load my images via a coroutine in this script:
IEnumerator Load()
{
Texture2D tex = new Texture2D(4, 4, TextureFormat.DXT1, false);
while (true)
{
WWW www = new WWW(url);
yield return www;
www.LoadImageIntoTexture(tex);
img.texture = tex;
}
}
(Where img.texture is my image in the scene and url is the url i'm loading from).
This works fine for loading the images, but I notice the images load/ stream faster once I start more coroutines. To clarify, if i have 1 image stream it's updating the images at a certain speed but if i have, e.g. 3 image streams (each having a coroutine for loading) suddenly all 3 streams load images faster than with 1 stream.
I tried adding a yield return new WaitForFixedUpdate();
at the end of the coroutine but it didn't help, and i have no idea how to achieve a regular pace in loading new images, independent how many streams/coroutines i have at the same time?
I hope it's clear what i mean and any help is appreciated!