Example #1
0
        /// <summary>
        /// 加载此包
        /// </summary>
        /// <returns></returns>
        public IEnumerator LoadBundle()
        {
            WWW bundleLoader = new WWW(PathTool.GetBundlePathByName(bundleName));

            while (!bundleLoader.isDone)
            {
                //TODO MgrCenter.Instance.SendMsg(MgrCenter.AssetMgr.GetBundleLoadProgressMsg((ushort)AssetLoadEvent.AssetLoadProgress, bundleName, bundleLoader.progress));
                isLoading = true;
                yield return(null);
            }

            if (string.IsNullOrEmpty(bundleLoader.error) && bundleLoader.progress >= 1.0f)
            {
                //TODO Send load finished msg
                isLoadFinished = true;
                isLoading      = false;
                assetBundle    = bundleLoader.assetBundle;

                SelfOnLoadFinished();
                //加载资源的loader
                resLoader = new ABResLoader(assetBundle, bundleName);
            }
            else
            {
                Debug.LogError(new StringBuilder("asset bundle load error, bundle name : ").Append(bundleName).Append(bundleLoader.error).ToString());
            }
        }
Example #2
0
        /// <summary>
        /// 释放这个包
        /// </summary>
        /// <param name="ifWithObj">是否将包加载出的Obj也一起释放</param>
        public void UnloadBundle(bool ifWithObj)
        {
            isLoading      = false;
            isLoadFinished = false;
            if (ifWithObj)
            {
                resLoader.Dispose();
                assetBundle.Unload(true);
            }
            else
            {
                assetBundle.Unload(false);
            }

            resLoader = null;
        }