コード例 #1
0
        /// <summary>
        /// Remove asset from local storage
        /// </summary>
        /// <param name="url">Url of the asset</param>
        public void RemoveAsset(string url)
        {
            if (mLocalAssets.ContainsKey(url))
            {
                // Delete file from local storage
                AssetHeader assetToRemove = mLocalAssets[url];
                assetToRemove.DeleteAsset();

                // Update lookup and manifest
                mLocalAssets.Remove(url);
                mAssetManifest.assetHeaders.Remove(assetToRemove);
                SaveAssetManifest();
            }
        }
コード例 #2
0
        public IEnumerator LoadAsset(string url, LoadCompleteCallback callback)
        {
            if (mLoadedAssets.ContainsKey(url))
            {
                callback(mLoadedAssets[url]);
                yield break;
            }

            // Load dependencies if exists
            AssetBundleCreateRequest asyncLoad = null;
            AssetHeader header = mLocalAssets[url];

            if (header.dependencies != null && header.dependencies.Length > 0)
            {
                foreach (var depUrl in header.dependencies)
                {
                    if (!mLoadedAssets.ContainsKey(depUrl))
                    {
                        asyncLoad = AssetBundle.LoadFromFileAsync(GetFullPath(depUrl));
                        yield return(asyncLoad);

                        mLoadedAssets.Add(depUrl, new Asset(mLocalAssets[depUrl], asyncLoad.assetBundle));
                    }
                }
            }

            // Load main asset bundle
            asyncLoad = AssetBundle.LoadFromFileAsync(GetFullPath(url));
            Asset asset = new Asset(mLocalAssets[url], asyncLoad.assetBundle);

            mLoadedAssets.Add(url, asset);
            yield return(asyncLoad);

            if (callback != null)
            {
                callback(asset);
            }
        }
コード例 #3
0
ファイル: Asset.cs プロジェクト: RookieDeveloper-Wang/Test
 public Asset(AssetHeader header, AssetBundle bundle)
 {
     this.header = header;
     this.bundle = bundle;
 }