WWW class download more than one file

Hello,

I want to do, that script could download not only one file,using WWW class, but all files from that folder or database and put it into array. Is it possible?

I just want that script could automatically find song files and upload them to array.

Here is my script, which fully works with one song, but I have to select song manually.

#pragma strict


var location = "file://C:/AUGUSTAS/Music/"; 
var file = "1.mp3";

 
function Start () {
    var fileAndLocation = location + file;    
   
    var www = new WWW(fileAndLocation);
    audio.clip = www.audioClip;    
    while (!www.isDone) {
        yield WaitForSeconds(1);
        if (audio.time > audio.clip.length-2) {
            audio.clip = www.audioClip;
            
        }
    }
    
}
 
function Update () {
    
    if(!audio.isPlaying  audio.clip.isReadyToPlay)
        audio.Play();
}

Any tips, scripts, comments would be appreciated.

Thanks,

Augustas

P.S I am using unity free.

The easier way to do this would be to run something like

var location = "file://C:/AUGUSTAS/Music/"; 

// i'm a bit rusty, may not work off the bat 
var location
var SongArray = String[] ;
var GotArray = [] ;
function Start (){
for( var i = 0 ;  i < SongArray.length  ; i ++){

SongGet(SongArray[i]) ;
}
 }

function SongGet (file) {

    var fileAndLocation = location + file;    

   

    var www = new WWW(fileAndLocation);

    audio.clip = www.audioClip;    

    while (!www.isDone) {

        yield WaitForSeconds(1);

        if (audio.time > audio.clip.length-2) {

            audio.clip = www.audioClip;

            GotArray.push(audio.clip) ;

        }

    }

    

}

That sound be 75% of the way their , but its untested , and you’ll have to fix it up a bit .

Hi, thanks for script, but it gives me error : push is not a member of Object[ ]. How can I solve this?

Here is the script:

var location = "file://C:/AUGUSTAS/Music/"; 

 

// i'm a bit rusty, may not work off the bat 



var SongArray : String[];

var GotArray = [] ;

function Start (){

for( var i = 0 ;  i < SongArray.length  ; i ++){

 

SongGet(SongArray[i]) ;

}

 }

 

function SongGet (file) {

 

    var fileAndLocation = location + file;    

 

   

 

    var www = new WWW(fileAndLocation);

 

    audio.clip = www.audioClip;    

 

    while (!www.isDone) {

 

        yield WaitForSeconds(1);

 

        if (audio.time > audio.clip.length-2) {

 

            audio.clip = www.audioClip;

 

            GotArray.push(audio.clip) ;

 

        }

 

    }  

 

}

Edit : Never mind got it working in a bit different way :slight_smile: