Loading imagesequence at runtime - memory problem

Hi there,

I’m loading 84 jpgs at runtime and I swap them every 1/2 frames. This goes well for 3 loops, after that Unity’s seems to be full and it displays 1 image every second. ( complete unity seems to be stuck for seconds, so i’m really sure its memory ) how can I improve the script, or is unity just not able to render a different texture every frame?

public	var frameSpeed:int = 2;

private	var baseUrl:String = "/mediaserver/";

private	var imageSequenceLength:int = 84;

private	var imageSequence:Array = [];
private	var imageIndex:int = 0;

private var	loadingIsComplete:boolean = false;

    function Start () {
    

           // LOAD IMAGES

    	for( var i:int = 1; i < imageSequenceLength + 1; i++ ) {
    	
    		// Debug.Log( "Load: " + baseUrl + "20120224125016" + digit2( i ) + ".jpg" );
    	
    		var www : WWW = new WWW ( baseUrl + "20120224125016" + digit2( i ) + ".jpg" );

                 // PUSH THEM INTO ARRAY

    		imageSequence.Push( www );
    		
    	}
    	
    }
    
    function Update () {

           
           // CHECK LOADING COMPLETE

    	if( loadingIsComplete ) {
    	
    		setNextImage();
    		
    	} else {
    	
    		Debug.Log("still loading... " + Time.time );
    	
    		loadingIsComplete = true;
    		
    		for( var i:int = 0; i < imageSequenceLength; i++ ) {
    		
    			if( !imageSequence[ i ].isDone ) {
    			
    				loadingIsComplete = false;
    				//Debug.Log( i + " is " + imageSequence[ i ].isDone );
    			}
    		}
    	}
    	
    }
    function setNextImage():void {
    
    	renderer.material.mainTexture = null;
    
    	imageIndex += frameSpeed;
    	
    	 if( imageIndex >= imageSequenceLength ) imageIndex = 0; 
    	
    	renderer.material.mainTexture = imageSequence[ imageIndex ].texture;
    	
    }
    
    function digit2( incoming:int ):String {
    
    	var str:String = incoming.ToString();
    
    	while( str.Length < 2 ) str = "0" + str;
    
    	return str;
    }

thanks in advance,

jochem

Found it.

Get the image out of the loader first in a seperate imageSequence array.

Then loop through the images instead of the loader.