Exemplo n.º 1
0
        /// <summary>
        /// 释放资源
        /// </summary>
        public void commonDispose()
        {
            //Debug.LogError("assetbundle =="+ bundleName);

            if (commonRes != null)
            {
                commonRes.Dispose();

                commonRes = null;

                bundleName = null;

                loadFinish = null;

                loadPorgress = null;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 加载公共资源
        /// </summary>

        /// <summary>
        /// 开始载入,在Unity3d环境中用StartCoroutine()来开始一个资源的载入
        ///
        /// commonResourcesPath ==file:///E:/SVN/3DFish/Project/Fish/Assets/StreamingAssets/AssetBundles/Windows/scenceone/prefeb.ld
        /// </summary>
        /// <returns></returns>
        public IEnumerator CommonLoad()
        {
            commonResourcesDone = 0;



            string bundlePath = IPathTools.GetAssetBundleFilePath(bundleName);

            //  Debuger.Log("bundlePath =="+ bundlePath);
            //判断persistent是否存在
            if (!IFileTools.IsExistFile(bundlePath))
            {
                bundlePath = IPathTools.GetAssetBundleWWWStreamPath(bundleName);

                WWW bundle = WWW.LoadFromCacheOrDownload(bundlePath, FrameTools.VersionId);

                yield return(bundle);



                if (!string.IsNullOrEmpty(bundle.error))
                {
                    Debuger.Log(bundle.error);

                    //  yield break;
                }
                else
                {
                    // Debug.Log("manifestPath =777777=" + bundle.progress);

                    commonResourcesDone = 1.0f;


                    commonRes = new ResIndexers(bundle.assetBundle);

                    //    Debug.Log("commonResourcesPath load finish= 2222=" + tmpRequest.assetBundle);


                    this.loadFinish(bundleName);
                    loadPorgress(bundleName, commonResourcesDone);
                }
            }
            else
            {
                AssetBundleCreateRequest tmpRequest = AssetBundle.LoadFromFileAsync(bundlePath);

                yield return(tmpRequest);



                if (tmpRequest.assetBundle != null)
                {
                    commonResourcesDone = 1.0f;
                    //  Debug.Log("commonResourcesPath load finish= 2222=" + bundleName);



                    commonRes = new ResIndexers(tmpRequest.assetBundle);

                    //    Debug.Log("commonResourcesPath load finish= 2222=" + tmpRequest.assetBundle);


                    this.loadFinish(bundleName);
                    loadPorgress(bundleName, commonResourcesDone);
                }
                else
                {
                    Debuger.LogError(" bundleName is not finish ==" + bundleName);

                    //  yield break;
                }
            }
        }