Example #1
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 #2
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);
        }
    }