コード例 #1
0
        public override AssetRequest <TAsset> LoadAsync <TAsset>(string deviceList, ref ContentManifest.AssetEntry entry, AssetLoadedHandler <TAsset> handler = null)
        {
            if (bundleManager.IsUnmounting(entry.BundleKey))
            {
                bundleManager.CancelUnmount(entry.BundleKey);
            }
            AssetRequest <TAsset> assetRequest;

            if (bundleManager.IsMounted(entry.BundleKey))
            {
                BundleMount bundle = bundleManager.GetBundle(entry.BundleKey);
                if (entry.Extension.Equals("unity"))
                {
                    assetRequest          = new SceneAssetBundleRequest <TAsset>(entry.Key, entry.BundleKey, null);
                    assetRequest.Finished = true;
                }
                else
                {
                    assetRequest = bundle.LoadAsync(entry.Key, entry.AssetPath, handler);
                }
            }
            else
            {
                AsyncAssetBundleRequest <TAsset> asyncAssetBundleRequest = ((!entry.Extension.Equals("unity")) ? new AsyncAssetBundleRequest <TAsset>(entry.Key, null) : new SceneAssetBundleRequest <TAsset>(entry.Key, entry.BundleKey, null));
                assetRequest = asyncAssetBundleRequest;
                CoroutineRunner.StartPersistent(loadBundleAndDependenciesAsync(deviceList, entry, asyncAssetBundleRequest, handler), this, "loadBundleAndDependenciesAsync");
            }
            return(assetRequest);
        }
コード例 #2
0
ファイル: Content.cs プロジェクト: smdx24/CPI-Source-Code
        private bool unload <TAsset>(string key, bool unloadAllObjects) where TAsset : class
        {
            key = key.ToLower();
            ContentManifest.AssetEntry assetEntry = getAssetEntry(key);
            TAsset indexedAsset = getIndexedAsset <TAsset>(key);

            if (indexedAsset != null)
            {
                string bundleKey = assetEntry.BundleKey;
                if (!string.IsNullOrEmpty(bundleKey) && bundleManager.IsMounted(assetEntry.BundleKey))
                {
                    bundleManager.UnmountBundle(bundleKey, unloadAllObjects);
                }
                assetIndex.Remove(assetEntry.Key);
                return(true);
            }
            return(false);
        }