Beispiel #1
0
        /// <summary>
        /// 从streamingAssetPath中加载包
        /// </summary>
        /// <param name="strABName"></param>
        /// <returns></returns>
        private IEnumerator _LoadAssetBundleAsycFromStreaming(string strABName)
        {
            string path = itfStreamingPath + strABName;

            Debug.Log("streamingAssetsPath: " + path);
            AssetBundleCreateRequest request = AssetBundle.LoadFromFileAsync(path);

            yield return(request);

            if (request != null &&
                request.assetBundle != null)
            {
                //包加载成功
                tagLoadedAssetBundle loadedBundle = new tagLoadedAssetBundle();
                loadedBundle.Init(request.assetBundle);
                m_dictLoadedAssetBundles.Add(strABName, loadedBundle);

                Debug.Log("load " + strABName + " bundle from streming succeed!");
            }
            else
            {
                //包加载失败
                Debug.Log("load assetBundle:" + strABName + "from streaming is invalid!");
            }
        }
Beispiel #2
0
        /// <summary>
        /// 从cache中加载包
        /// </summary>
        /// <param name="strABName"></param>
        /// <returns></returns>
        private IEnumerator _LoadAssetBundleAsycFromCache(string strABName)
        {
            //检查manifest
            if (m_assetBundleManifest == null ||
                AssetBundleInfoManager.IsExits() ||
                AssetBundleInfoManager.GetSingel().GetBundleInfo(itfDownloadPath) == null ||
                AssetBundleInfoManager.GetSingel().GetBundleInfo(itfDownloadPath).IsCached(strABName) == false)
            {
                Debug.LogError("LoadAssetBundleFromCache error!");
                yield break;
            }

            //加载包
            string path = itfDownloadPath + strABName;
            AssetBundleCreateRequest request = AssetBundle.LoadFromFileAsync(path);

            yield return(request);

            if (request.isDone &&
                request.assetBundle != null)
            {
                //包加载成功
                tagLoadedAssetBundle loadedBundle = new tagLoadedAssetBundle();
                loadedBundle.Init(request.assetBundle);
                m_dictLoadedAssetBundles.Add(strABName, loadedBundle);

                Debug.Log("load " + strABName + " bundle from cache succeed!");
            }
            else
            {
                //包加载失败
                Debug.Log("load assetBundle:" + strABName + "from cache is invalid!");
            }
        }