Exemple #1
0
        private IPromise <T> ProcessBundle <T>(string bundleId, string assetName, AssetBundle bundle) where T : UnityEngine.Object
        {
            if (bundle != null)
            {
                T result = bundle.LoadAsset <T>(assetName);

                AddAssetToCache(bundleId, assetName, result);

                AssetBundleLoader.Unload(assetBundles[bundleId].url, assetBundles[bundleId].version, false);

                return(new Promise <T>((resolve, reject) =>
                {
                    resolve(result);
                }));
            }
            else
            {
                return(new Promise <T>((resolve, reject) =>
                {
                    reject(new ApplicationException(string.Format("Failed to load asset bundle {0}.", bundleId)));
                }));
            }
        }