Ejemplo n.º 1
0
 public void StartLoadAB()
 {
     if (modelManager.loadingBunles.Contains(ABName))
     {
         StartCoroutine(WaitToLoad());
     }
     else
     {
         bool bundleTaken = false;
         foreach (AssetBundle ab in modelManager.bundles)
         {
             Debug.Log("ab.name = " + ab.name);
             if (ab.name.Equals(ABName))
             {
                 Instantiate(ab.LoadAssetAsync(AssetName).asset, gameObject.transform);
                 Debug.Log("Loaded twice or MORE");
                 preloader.Loaded();
                 bundleTaken = true;
             }
         }
         if (!bundleTaken)
         {
             StartCoroutine(LoadAsset());
         }
     }
 }
Ejemplo n.º 2
0
    IEnumerator DownloadAndCache()
    {
        // Wait for the Caching system to be ready
        preloader.Loading();
        isRun = true;
        Debug.Log("isRunningTRUE");
        while (!Caching.ready)
        {
            yield return(null);
        }
        Debug.Log("Caching ready");
        // Load the AssetBundle file from Cache if it exists with the same version or download and store it in the cache
        using (WWW www = WWW.LoadFromCacheOrDownload(BundleFullURL, version))
        {
            Debug.Log("Loading ready");
            if (www.error == null)
            {
                preloader.LoadPercent(www);
            }
            yield return(www);

            if (www.error != null)
            {
                Debug.Log(ABName + " not downloaded. Error" + www.error);
                preloader.CantLoad();
            }
            else
            {
                AssetBundle bundle = www.assetBundle;
                if (AssetName == "" && TextAssetName == "")
                {
                    Debug.Log("Asset name not assigned");
                }
                else
                {
                    Debug.Log("Asset ready");
                    if (bundle.Contains(AssetName))
                    {
                        Instantiate(bundle.LoadAsset(AssetName), gameObject.transform);
                        objectActive = true;
                        Debug.Log("is OBJ");
                        preloader.Loaded();
                    }
                    else
                    {
                        Debug.Log("Check asset name");
                    }
                }
                // Unload the AssetBundles compressed contents to conserve memory
                bundle.Unload(false);
            }
            www.Dispose();
        }
        Debug.Log("isRunningFALSE");
        isRun = false;
        if (onRequestLost)
        {
            OnTrackingLost();
        }
    }