Inheritance: UnityEngine.MonoBehaviour
Ejemplo n.º 1
0
 void Awake()
 {
     Instance = this;
 }
Ejemplo n.º 2
0
        private void Update()
        {
            this.keysToRemove.Clear();
            foreach (KeyValuePair <string, LoadedAssetBundle> keyValuePair in AssetBundleManager.m_ToUnloadAssetBundles)
            {
                if (keyValuePair.Value != null && ++keyValuePair.Value.m_UnloadTicks >= 60)
                {
                    keyValuePair.Value.m_AssetBundle.Unload(true);
                    this.keysToRemove.Add(keyValuePair.Key);
                }
            }
            for (int i = 0; i < this.keysToRemove.Count; i++)
            {
                string key = this.keysToRemove[i];
                AssetBundleManager.m_ToUnloadAssetBundles.Remove(key);
            }
            this.keysToRemove.Clear();
            foreach (KeyValuePair <string, AssetBundleCreateRequest> keyValuePair2 in AssetBundleManager.m_DownloadingReqs)
            {
                AssetBundleCreateRequest value = keyValuePair2.Value;
                if (value.isDone)
                {
                    AssetBundle assetBundle = value.assetBundle;
                    if (assetBundle == null)
                    {
                        if (!AssetBundleManager.m_DownloadingErrors.ContainsKey(keyValuePair2.Key))
                        {
                            AssetBundleManager.m_DownloadingErrors.Add(keyValuePair2.Key, string.Format("{0} is not a valid asset bundle.", keyValuePair2.Key));
                        }
                        this.keysToRemove.Add(keyValuePair2.Key);
                    }
                    else
                    {
                        int num = AssetBundleManager.m_DownloadingTicks[keyValuePair2.Key];
                        if (num > 0)
                        {
                            AssetBundleManager.m_LoadedAssetBundles.Add(keyValuePair2.Key, new LoadedAssetBundle(assetBundle, num));
                        }
                        else
                        {
                            assetBundle.Unload(true);
                            AssetBundleManager.UnloadDependencies(keyValuePair2.Key);
                            for (int j = AssetBundleManager.m_InProgressOperations.Count - 1; j >= 0; j--)
                            {
                                if (AssetBundleManager.m_InProgressOperations[j].MatchBundle(keyValuePair2.Key))
                                {
                                    AssetBundleManager.m_InProgressOperations[j].Abort();
                                    AssetBundleManager.m_InProgressOperations.RemoveAt(j);
                                }
                            }
                        }
                        this.keysToRemove.Add(keyValuePair2.Key);
                    }
                }
            }
            foreach (string key2 in this.keysToRemove)
            {
                AssetBundleManager.m_DownloadingReqs.Remove(key2);
                AssetBundleManager.m_DownloadingTicks.Remove(key2);
            }
            int k = 0;

            while (k < AssetBundleManager.m_InProgressOperations.Count)
            {
                if (!AssetBundleManager.m_InProgressOperations[k].Update())
                {
                    AssetBundleManager.m_InProgressOperations.RemoveAt(k);
                }
                else
                {
                    k++;
                }
            }
        }
Ejemplo n.º 3
0
 public static bool LoadAssetAsyncCallback <T>(string assetBundleName, string assetName, Func <T, bool> onAssetLoaded) where T : UnityEngine.Object
 {
     AssetBundleManager.Initialize();
     if (AssetBundleManager.m_Instance)
     {
         if (string.IsNullOrEmpty(assetBundleName) || string.IsNullOrEmpty(assetName))
         {
             Debug.LogError("## Empty bundle or asset name: assetBundleName=" + assetBundleName + ", assetName=" + assetName);
             return(false);
         }
         AssetBundleLoadAssetOperation assetBundleLoadAssetOperation = AssetBundleManager.LoadAssetAsync(assetBundleName, assetName, typeof(T));
         if (assetBundleLoadAssetOperation != null)
         {
             if (!AssetBundleManager.m_PendingRoutines.ContainsKey(onAssetLoaded))
             {
                 Coroutine value = AssetBundleManager.m_Instance.StartCoroutine(AssetBundleManager.LoadAssetAsyncCallbackRoutine <T>(assetBundleName, assetBundleLoadAssetOperation, onAssetLoaded));
                 AssetBundleManager.m_PendingRoutines.Add(onAssetLoaded, value);
             }
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 4
0
 public void InitializeInstance()
 {
     AssetBundleManager.Initialize();
 }
Ejemplo n.º 5
0
 public static void SetSourceAssetBundleDirectory(string relativePath)
 {
     AssetBundleManager.BaseDownloadingURL = AssetBundleManager.GetStreamingAssetsPath() + relativePath;
 }
Ejemplo n.º 6
0
 private void Start()
 {
     abm = new AssetBundleManager();
     abm.SetBaseUri("https://www.example.com/bundles");
     abm.Initialize(OnAssetBundleManagerInitialized);
 }
 public AssetBundleLoadOperationFull(string bundleName)
 {
     m_AssetBundleName = bundleName;
     www = AssetBundleManager.GetAssetBundleWWW(bundleName);
 }
 static AssetBundleManagerAPI()
 {
     AssetBundleManager.Init();
 }