private void Update()
 {
     if (this.assetsToLoad.Count > 0)
     {
         for (int i = this.assetsToLoad.Count - 1; i >= 0; i--)
         {
             LoadAssetFromBundle loadAssetFromBundle = this.assetsToLoad[i];
             if (loadAssetFromBundle.IsDownloadDone)
             {
                 loadAssetFromBundle.InstantiateAsset();
                 this.assetsToLoad.RemoveAt(i);
                 UnityEngine.Object.Destroy(loadAssetFromBundle);
                 this.isDownloaded = true;
             }
         }
         if (this.isDownloaded)
         {
             foreach (LoadAssetFromBundle current in this.assetsToLoad)
             {
                 if (!current.HasDownloadStarted)
                 {
                     current.DownloadAsset();
                     this.isDownloaded = false;
                     break;
                 }
             }
         }
     }
     else
     {
         UnityEngine.Object.Destroy(base.gameObject);
     }
 }
Example #2
0
    // Update is called once per frame
    void Update()
    {
        if (assetsToLoad.Count > 0)
        {
            for (int i = (assetsToLoad.Count - 1); i >= 0; i--)
            {
                LoadAssetFromBundle asset = assetsToLoad[i];
                if (asset.IsDownloadDone)
                {
//					string fileName = Application.persistentDataPath + "/" + FILE_NAME;
//					fileWriter = File.CreateText(fileName);
//					fileWriter.WriteLine("Hello world");
//					fileWriter.Close();

                    //The download is done, instantiate the asset from the bundle
                    asset.InstantiateAsset();
                    //Remove the asset from the loading list
                    assetsToLoad.RemoveAt(i);
                    //Destroy the LoadAssetFromBundle Script
                    Destroy(asset);
                    //This means an asset is downloaded, which means you can start on the next one
                    isDownloaded = true;
                }
            }

            if (isDownloaded)             //The download is complete
            {
                //Start the next download
                foreach (LoadAssetFromBundle asset in assetsToLoad)
                {
                    if (!asset.HasDownloadStarted)
                    {
                        //Start the download
                        asset.DownloadAsset();

                        //set the isDownloaded to false again
                        isDownloaded = false;

                        //break the loop
                        break;
                    }
                }
            }
        }
        else         //If there is nothing left to load, then destroy this game object
        {
            //Destroy(this.gameObject);
        }
    }
Example #3
0
    void Update()
    {
        if (assetsToLoad.Count > 0)
        {
            for (int i = (assetsToLoad.Count - 1); i >= 0; i--)
            {
                LoadAssetFromBundle asset = assetsToLoad[i];
                if (asset.IsDownloadDone)
                {
                    //The download is done, instantiate the asset from the bundle
                    asset.InstantiateAsset();
                    //Remove the asset from the loading list
                    assetsToLoad.RemoveAt(i);
                    //Destroy the LoadAssetFromBundle Script
                    Destroy(asset);
                    //This means an asset is downloaded, which means you can start on the next one
                    isDownloaded = true;
                }
            }

            if (isDownloaded) //The download is complete
            {
                //Start the next download
                foreach (LoadAssetFromBundle asset in assetsToLoad)
                {
                    if (!asset.HasDownloadStarted)
                    {
                        //Start the download
                        asset.DownloadAsset();

                        //set the isDownloaded to false again
                        isDownloaded = false;

                        //break the loop
                        break;
                    }
                }
            }
        }
        else         //If there is nothing left to load, then destroy this game object
        {
            Destroy(this.gameObject);
        }
    }