Hello,
i’m loading some textures from a webserver with unity’s www-class. If the download is done, i write the downloaded texture in a texture that i created before.
I do that with www.LoadImageIntoTexture(myTexture).
At this point the renderer stops for some frames and continue if the texture has changed.
Here is my code:
WWW www = www = new WWW([url]http://.[/url]..);
Texture2D texture = new Texture2D(1, 1, TextureFormat.ARGB32, true);
texture.filterMode = FilterMode.Trilinear;
texture.wrapMode = TextureWrapMode.Clamp;
www.LoadImageIntoTexture(texture);
texture.Compress(true);
Any ideas why the renderer stops for a while?
If the texture is large, there might be a lot of data to process. Are you doing this with the iPhone, by the way?
no, the application run in the webplayer. in the editor the renderer stops too. the textures are 512x256 in jpeg-format.
Hi,
I know this is an old thread, but I’m experiencing the same hiccups when the Image is retrieved, and I’m just making a Pong clone where the background changes every 15 seconds:
var url = "http://images.earthcam.com/ec_metros/ourcams/fridays.jpg";
var imageTimer:float;
var changeFrequency:float = 15.0;
var loading:boolean = false;
function Start () {
// Create a texture in DXT1 format
renderer.material.mainTexture = new Texture2D(4, 4, TextureFormat.DXT1, false);
imageTimer = changeFrequency;
}
function Update(){
if (!loading){
imageTimer -= Time.deltaTime;
if (imageTimer <= 0){
LoadImage();
}
}
}
function LoadImage(){
loading = true;
// Start a download of the given URL
var www = new WWW(url);
// wait until the download is done
yield www;
// assign the downloaded image to the main texture of the object
www.LoadImageIntoTexture(renderer.material.mainTexture);
loading = false;
imageTimer = changeFrequency;
}
Just before swapping the image, the game halts for some frames, making it painfully unplayable. I there any way to avoid this?
Thanks!
Make the image smaller so the hiccup isn’t as noticeable, but other than that, no, not as far as I know of. Either that or avoid the issue altogether by loading the graphics beforehand.
–Eric
Resurrection bump.
Is there a workaround?