Example #1
0
 public void SetContent(string text)
 {
     textContent.text = text;
     // ResizeBoxSize();
     //需要在这帧结束改变 textbox 的大小
     IEnumeratorTool.StartCoroutine(IE_ChangeBoxSize());
 }
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="path"></param>
        public AssetBundleManifestReference(string path)
        {
            //加载manifest
            IEnumeratorTool.StartCoroutine(IELoadManifest(path, b =>
            {
                if (b)
                {
                    BDebug.Log("manifest加载成功!");
                    AssetBundlesSet = new HashSet <string>();
                    var list        = this.Manifest.GetAllAssetBundles();
                    foreach (var l in list)
                    {
                        AssetBundlesSet.Add(l);
                    }
                }
                else
                {
                    BDebug.LogError("manifest加载失败!");
                }

                //通知到BDFrameLife
                var dd = DataListenerServer.GetService("BDFrameLife");
                dd.TriggerEvent("OnAssetBundleOever");
            }));
        }
        /// <summary>
        /// 加载ab
        /// </summary>
        /// <param name="path"></param>
        /// <param name="callback"></param>
        private void AsyncLoadAssetBundle(string path, Action <bool> callback)
        {
            //ab存储的是asset下的相对目录
            path = "assets/resource/runtime/" + path.ToLower() + ".";
            //寻找ab的后缀名
            var mainAssetPath = GetExistPath(path);

            if (mainAssetPath != null)
            {
                //1.依赖资源
                var res = manifest.Manifest.GetDirectDependencies(mainAssetPath).ToList();
                //2.主体资源
                res.Add(mainAssetPath);


                //补全路径
                Stack <string> stack = new Stack <string>();
                foreach (var r in res)
                {
                    var fullPath = IPath.Combine(this.artRootPath, r);
                    stack.Push(fullPath);
                }

                //开始加载队列
                IEnumeratorTool.StartCoroutine(IEAsyncLoadAssetbundle(stack, callback));
            }
            else
            {
                Debugger.LogError("没有该资源:" + path);
                //没有该资源
                callback(false);
            }
        }
        /// <summary>
        /// assetdatabase 不支持异步,暂时先做个加载,后期用update模拟异步
        /// </summary>
        /// <param name="sources"></param>
        /// <param name="onLoadComplete"></param>
        /// <param name="onLoadProcess"></param>
        /// <returns></returns>
        public List <int> AsyncLoad(IList <string> sources, Action <IDictionary <string, Object> > onLoadComplete, Action <int, int> onLoadProcess)
        {
            IDictionary <string, UnityEngine.Object> map = new Dictionary <string, Object>();

            //每帧加载5个
            IEnumeratorTool.StartCoroutine(TaskUpdate(5, sources, (s, o) =>
            {
                map[s] = o;
                //
                if (onLoadProcess != null)
                {
                    onLoadProcess(map.Count, sources.Count);
                }

                //
                if (map.Count == sources.Count)
                {
                    if (onLoadComplete != null)
                    {
                        onLoadComplete(map);
                    }
                }
            }));

            return(new List <int>());
        }
Example #5
0
        /// <summary>
        /// assetdatabase 不支持异步,暂时先做个加载,后期用update模拟异步
        /// </summary>
        /// <param name="assetsPath"></param>
        /// <param name="onLoadComplete"></param>
        /// <param name="onLoadProcess"></param>
        /// <returns></returns>
        public List <int> AsyncLoad(IList <string> assetsPath,
                                    Action <IDictionary <string, Object> > onLoadComplete,
                                    Action <int, int> onLoadProcess)
        {
            //var list = assetsPath.Distinct().ToList();

            IDictionary <string, UnityEngine.Object> map = new Dictionary <string, Object>();
            int curProcess = 0;

            //每帧加载1个
            IEnumeratorTool.StartCoroutine(TaskUpdate(1, assetsPath, (s, o) =>
            {
                curProcess++;
                map[s] = o;
                //
                if (onLoadProcess != null)
                {
                    onLoadProcess(curProcess, assetsPath.Count);
                }

                //
                if (curProcess == assetsPath.Count)
                {
                    if (onLoadComplete != null)
                    {
                        onLoadComplete(map);
                    }
                }
            }));

            return(new List <int>());
        }
Example #6
0
        //
        /// <summary>
        /// 游戏逻辑的Assembly
        /// </summary>
        //        public static  Assembly GameAssembly { get; private set; }
        /// <summary>
        /// 开始热更脚本逻辑
        /// </summary>
        private void LoadScrpit(string root)
        {
            if (root != "") //热更代码模式
            {
                if (Config.CodeRunMode == HotfixCodeRunMode.ByILRuntime)
                {
                    //解释执行模式
                    ILRuntimeHelper.LoadHotfix(root);
                    ILRuntimeHelper.AppDomain.Invoke("BDLauncherBridge", "Start", null, new object[] { true });
                }
                else
                {
                    //
                    //反射模式
                    string dllPath = root + "/" + Utils.GetPlatformPath(Application.platform) + "/hotfix/hotfix.dll";

                    IEnumeratorTool.StartCoroutine(this.IE_LoadScript(dllPath));
                }
            }
            else
            {
                //PC 模式非热更

                //这里用反射是为了 不访问逻辑模块的具体类,防止编译失败
                var assembly = Assembly.GetExecutingAssembly();
                //
                var type   = assembly.GetType("BDLauncherBridge");
                var method = type.GetMethod("Start", BindingFlags.Public | BindingFlags.Static);
                method.Invoke(null, new object[] { false });
            }
        }
Example #7
0
        public void Load(string path, Action onLoaded)
        {
            this.onLoaded = onLoaded;

            if (Application.isEditor)
            {
                //这里开个同步接口 为了单元测试用
                if (File.Exists(path))
                {
                    BDebug.Log("manifest加载成功!");
                    var text = File.ReadAllText(path);
                    this.Manifest = new ManifestConfig(text);
                    this.onLoaded?.Invoke();
                    this.onLoaded = null;
                }
                else
                {
                    Debug.LogError("配置文件不存在:" + path);
                }
            }
            else
            {
                //加载manifest
                IEnumeratorTool.StartCoroutine(IE_LoadConfig(path));
            }
        }
        /// <summary>
        /// 递归加载
        /// </summary>
        /// <param name="path"></param>
        /// <param name="sucessCallback"></param>
        /// <returns></returns>
        IEnumerator IEAsyncLoadAssetbundle(Queue <string> loadQueue, Action <bool> callback)
        {
            if (loadQueue.Count <= 0)
            {
                callback(true);
                yield break;
            }
            else
            {
                var path   = loadQueue.Dequeue();
                var result = AssetBundle.LoadFromFileAsync(path);
                yield return(result);

                if (result.isDone)
                {
                    //添加assetbundle
                    if (result.assetBundle != null)
                    {
                        AddAssetBundle(result.assetBundle.name, result.assetBundle);
                    }

                    //开始下个任务
                    IEnumeratorTool.StartCoroutine(IEAsyncLoadAssetbundle(loadQueue, callback));
                    yield break;
                }
                else
                {
                    BDebug.LogError("加载失败:" + path);
                }
            }
        }
        /// <summary>
        /// 递归加载
        /// </summary>
        /// <param name="path"></param>
        /// <param name="sucessCallback"></param>
        /// <returns></returns>
        IEnumerator IELoadAssetBundles(Queue <string> resQue, Action <bool> callback)
        {
            string path;

            if (resQue.Count <= 0)
            {
                callback(true);
                yield break;
            }
            else
            {
                path = resQue.Dequeue();
            }

            BDebug.Log("加载依赖:" + path);

            WWW www = new WWW(path);

            yield return(www);

            if (www.error == null)
            {
                if (www.isDone)
                {
                    UseAssetBunle(path, www.assetBundle);
                    //刷出
                    IEnumeratorTool.StartCoroutine(IELoadAssetBundles(resQue, callback));
                    yield break;
                }
            }
            else
            {
                Debug.LogError("加载失败:" + path);
            }
        }
Example #10
0
 Task now;//当前任务
 void DoNext()
 {
     if (httpTask.Count > 0)
     {
         now = httpTask.Dequeue();
         IEnumeratorTool.StartCoroutine(DoTask(now));
     }
 }
 public void Do(IBattle battle, IHeroFSM selfFSM, IHeroFSM targetFSM)
 {
     targetFSM.HeroGraphic.PlayAction("behurt");
     IEnumeratorTool.StartCoroutine(CheckAniEnd(targetFSM, "behurt", () =>
     {
         targetFSM.HeroGraphic.PlayAction("idle");
     }));
 }
Example #12
0
        /// <summary>
        /// 分组执行任务,每组加载ASYNC_TASK_NUM个任务
        /// </summary>
        public void DoNextTask()
        {
            if (isStop)
            {
                return;
            }

            //获取一个任务
            while (taskList.Count > 0 && curDoTaskConter < ASYNC_TASK_NUM)
            {
                var task = taskList[0];
                taskList.RemoveAt(0);
                //这一步确保主资源最后加载,防止资源自动依赖丢失
                if (task.IsMainAsset && taskList.Count != 0)
                {
                    taskList.Add(task);
                    continue;
                }
                //主资源才加载
                IEnumeratorTool.StartCoroutine(IE_AsyncLoadAssetbundle(task, (ret) =>
                {
                    curDoTaskConter--;

                    switch (ret)
                    {
                    case LoadAssetState.IsLoding:
                        //正在加载,需要重新压入task
                        taskList.Add(task);
                        break;

                    case LoadAssetState.Fail:
                    case LoadAssetState.Success:
                        {
                            if (isStop)
                            {
                                return;
                            }
                            //判断任务进度
                            if (curDoTaskConter > 0)
                            {
                                this.DoNextTask();
                            }
                            else
                            {
                                //总进度通知
                                IsComplete  = true;
                                var instObj = loder.LoadFormAssetBundle <Object>(this.MainAssetName, this.manifestItem);
                                OnAllTaskCompleteCallback?.Invoke(MainAssetName, instObj);
                            }
                        }
                        break;
                    }
                }));

                curDoTaskConter++;
            }
        }
Example #13
0
        /// <summary>
        /// 递归加载
        /// </summary>
        /// <param name="path"></param>
        /// <param name="sucessCallback"></param>
        /// <returns></returns>
        IEnumerator IEAsyncLoadAssetbundle(List <string> resList, Action <bool> callback)
        {
            if (resList.Count == 0)
            {
                callback(true);
            }
            else
            {
                //弹出一个任务
                var res = resList[0];
                resList.RemoveAt(0);
                if (res.EndsWith(".shader"))
                {
                    int i = 0;
                }
                var mainItem = manifest.Manifest.GetManifestItem(res);
                //单ab 多资源,加载真正ab名
                if (mainItem != null && !string.IsNullOrEmpty(mainItem.PackageName))
                {
                    res = mainItem.PackageName;
                }

                if (!currentLoadingABNames.Contains(res) && !assetbundleMap.ContainsKey(res))
                {
                    //加入列表防止同时加载一个
                    currentLoadingABNames.Add(res);
                    //
                    var resPath = FindAsset(res);
                    //开始加载
                    var result = AssetBundle.LoadFromFileAsync(resPath);
                    yield return(result);

                    //加载结束
                    if (result.isDone)
                    {
                        //移除当前列表
                        currentLoadingABNames.Remove(res);
                        //添加assetbundle
                        if (result.assetBundle != null)
                        {
                            AddAssetBundle(res, result.assetBundle);
                        }
                        else
                        {
                            BDebug.LogError("ab资源为空:" + resPath);
                        }
                    }
                }

                //开始下个任务
                IEnumeratorTool.StartCoroutine(IEAsyncLoadAssetbundle(resList, callback));
                yield break;
            }
        }
        public override void Start()
        {
            base.Start();
            foreach (var cd in this.GetAllClassDatas())
            {
                var attr = cd.Attribute as ComponentAdaptorProcessAttribute;
                adaptorMap[attr.Type] = CreateInstance <AComponentAdaptor>(cd);
            }

            //执行30s清理一次的cache
            IEnumeratorTool.StartCoroutine(this.IE_ClearCache(30));
        }
        /// <summary>
        /// 开始热更脚本逻辑
        /// </summary>
        static public void Load(string root, HotfixCodeRunMode mode)
        {
            if (root != "")
            {
                IEnumeratorTool.StartCoroutine(IE_LoadScript(root, mode));
            }
            else
            {
#if UNITY_EDITOR
                BDebug.Log("内置code模式!");
                BDLauncherBridge.Start();
#endif
            }
        }
Example #16
0
 private void showInputContents()
 {
     if (tempInputContents.Count == tempDialData.Count)
     {
         return;
     }
     while (tempInputContents.Count > tempDialData.Count)
     {
         GameObject.DestroyImmediate(tempInputContents[tempInputContents.Count - 1].Transform.gameObject);
         tempInputContents.RemoveAt(tempInputContents.Count - 1);
     }
     txt_Num.text = tempDialData.Count.ToString();
     IEnumeratorTool.StartCoroutine(createInputContent());
 }
Example #17
0
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="rootPath"></param>
        public void Init(string rootPath)
        {
            //多热更切换,需要卸载
            if (this.AssetConfigLoder != null)
            {
                this.UnloadAllAsset();
            }

            var platformPath = BApplication.GetRuntimePlatformPath();

            //1.设置加载路径
            if (Application.isEditor)
            {
                firstArtDirectory = IPath.Combine(rootPath, platformPath, BResources.ART_ASSET_ROOT_PATH);
                secArtDirectory   = IPath.Combine(Application.streamingAssetsPath, platformPath, BResources.ART_ASSET_ROOT_PATH); //
            }
            else
            {
                firstArtDirectory = IPath.Combine(Application.persistentDataPath, platformPath, BResources.ART_ASSET_ROOT_PATH);
                secArtDirectory   = IPath.Combine(Application.streamingAssetsPath, platformPath, BResources.ART_ASSET_ROOT_PATH); //
            }

            //2.路径替换
            firstArtDirectory = IPath.ReplaceBackSlash(firstArtDirectory);
            secArtDirectory   = IPath.ReplaceBackSlash(secArtDirectory);

            //3.加载ArtConfig
            this.AssetConfigLoder = new AssetbundleConfigLoder();
            var assetconfigPath = "";
            var assetTypePath   = "";

            if (Application.isEditor)
            {
                assetconfigPath = IPath.Combine(rootPath, platformPath, BResources.ART_ASSET_CONFIG_PATH);
                assetTypePath   = IPath.Combine(rootPath, platformPath, BResources.ART_ASSET_TYPES_PATH);
            }
            else
            {
                //真机环境config在persistent,跟dll和db保持一致
                assetconfigPath = IPath.Combine(Application.persistentDataPath, platformPath, BResources.ART_ASSET_CONFIG_PATH);
                assetTypePath   = IPath.Combine(Application.persistentDataPath, platformPath, BResources.ART_ASSET_TYPES_PATH);
            }

            this.AssetConfigLoder.Load(assetconfigPath, assetTypePath);
            //开始异步任务刷新
            IEnumeratorTool.StartCoroutine(this.IE_AsyncTaskListUpdte());
            BDebug.Log($"【AssetBundleV2】 firstDir:{firstArtDirectory}", "red");
            BDebug.Log($"【AssetBundleV2】 secDir:{secArtDirectory}", "red");
        }
        public void AsyncLoadManifest(string path, Action <bool> callback)
        {
            //如果存在 不让加载
            //if (manifest != null)
            //{
            //    callback(true);
            //    return;
            //}
            path = Path.Combine(LocalHotUpdateResPath, path);
#if UNITY_EDITOR || UNITY_IPHONE
            path = "File:///" + path;
#endif
            path = path.Replace("\\", "/");
            IEnumeratorTool.StartCoroutine(IELoadAssetBundles(path, callback, true));
        }
        public int LoadAsync <T>(string objName, Action <bool, T> action, bool isCreateTaskid = true) where T : UnityEngine.Object
        {
            //创建任务序列
            int taskid = -1;

            if (isCreateTaskid)
            {
                taskid = CreateTaskHash();
                taskHashSet.Add(taskid);
            }

            AsyncTask task = new AsyncTask();

            task.id = taskid;
            task.RegTask(() =>
            {
                if (objsMap.ContainsKey(objName))
                {
                    //判断任务结束
                    task.EndTask();
                    //有创建taskid的,判断段taskid是否存在
                    if (isCreateTaskid == true && taskHashSet.Contains(taskid) == false)
                    {
                        BDebug.Log("没发现任务id,不执行回调");
                        return;
                    }
                    action(true, objsMap[objName] as T);
                }
                else
                {
                    IEnumeratorTool.StartCoroutine(IELoadAsync <T>(objName, (bool b, T t) =>
                    {
                        //判断任务结束
                        task.EndTask();
                        //有创建taskid的,判断段taskid是否存在
                        if (isCreateTaskid == true && taskHashSet.Contains(taskid) == false)
                        {
                            BDebug.Log("没发现任务id,不执行回调");
                            return;
                        }
                        action(b, t);
                    }));
                }
            });

            asyncTaskList.Add(task);
            return(taskid);
        }
        public override void Start()
        {
            base.Start();
            var clsList = this.GetAllClassDatas();

            foreach (var cd in clsList)
            {
                var attr = cd.Attribute as ComponentBindAdaptorAttribute;
                var inst = CreateInstance <AComponentBindAdaptor>(cd);
                componentBindAdaptorMap[attr.BindType] = inst;
            }


            //执行30s清理一次的cache
            IEnumeratorTool.StartCoroutine(this.IE_ClearCache(30));
        }
Example #21
0
 /// <summary>
 /// 开始热更脚本逻辑
 /// </summary>
 static public void Load(string root, HotfixCodeRunMode mode)
 {
     if (root != "")
     {
         IEnumeratorTool.StartCoroutine(IE_LoadScript(root, mode));
     }
     else
     {
         BDebug.Log("内置code模式!");
         //反射调用,防止编译报错
         var assembly = Assembly.GetExecutingAssembly();
         var type     = assembly.GetType("BDLauncherBridge");
         var method   = type.GetMethod("Start", BindingFlags.Public | BindingFlags.Static);
         method.Invoke(null, new object[] { false, false });
     }
 }
        static StackObject *StartCoroutine_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 1);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            System.Collections.IEnumerator @ie = (System.Collections.IEnumerator) typeof(System.Collections.IEnumerator).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);


            var result_of_this_method = IEnumeratorTool.StartCoroutine(@ie);

            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value      = result_of_this_method;
            return(__ret + 1);
        }
        /// <summary>
        /// 递归加载
        /// </summary>
        /// <param name="path"></param>
        /// <param name="sucessCallback"></param>
        /// <returns></returns>
        IEnumerator IEAsyncLoadAssetbundle(List <string> resList, Action <bool> callback)
        {
            if (resList.Count == 0)
            {
                callback(true);
                yield break;
            }
            else
            {
                //弹出一个任务
                var res = resList[0];
                resList.RemoveAt(0);

                if (!assetbundleMap.ContainsKey(res))
                {
                    var resPath = FindAsset(res);

                    //开始加载
                    var result = AssetBundle.LoadFromFileAsync(resPath);
                    yield return(result);

                    //加载结束
                    if (result.isDone)
                    {
                        //添加assetbundle
                        if (result.assetBundle != null)
                        {
                            AddAssetBundle(res, result.assetBundle);
                        }
                        else
                        {
                            BDebug.LogError("ab资源为空:" + resPath);
                        }
                    }
                }
                else
                {
                    BDebug.Log("已存在,無需加載:" + res);
                }



                //开始下个任务
                IEnumeratorTool.StartCoroutine(IEAsyncLoadAssetbundle(resList, callback));
            }
        }
        /// <summary>
        /// 递归加载
        /// </summary>
        /// <param name="path"></param>
        /// <param name="sucessCallback"></param>
        /// <returns></returns>
        IEnumerator IEAsyncLoadAssetbundle(Stack <string> loadStack, Action <bool> callback)
        {
            if (loadStack.Count == 0)
            {
                callback(true);
            }
            else
            {
                //弹出一个任务
                var path = loadStack.Pop();

                //如果存在,直接执行下一个
                if (assetbundleMap.ContainsKey(path))
                {
                    IEnumeratorTool.StartCoroutine(IEAsyncLoadAssetbundle(loadStack, callback));
                    assetbundleMap[path].Use();
                    yield break;
                }


                //开始加载
                var result = AssetBundle.LoadFromFileAsync(path);
                yield return(result);

                //加载结束
                if (result.isDone)
                {
                    //添加assetbundle
                    if (result.assetBundle != null)
                    {
                        AddAssetBundle(path, result.assetBundle);
                    }
                    else
                    {
                        Debugger.LogError("ab资源为空:" + path);
                    }
                }
                else
                {
                    Debugger.LogError("加载失败:" + path);
                }
                //开始下个任务
                IEnumeratorTool.StartCoroutine(IEAsyncLoadAssetbundle(loadStack, callback));
            }
        }
Example #25
0
        /// <summary>
        /// 检测StreamingAsset下的资源包版本
        /// StreamingAsset 和 Persistent对比
        /// </summary>
        /// <param name="callback"></param>
        static public void CheckAssetPackageVersion(RuntimePlatform platform, Action callback)
        {
            switch (platform)
            {
            //android沙盒用www访问
            case RuntimePlatform.Android:
            {
                IEnumeratorTool.StartCoroutine(AndroidCheckAssetPackageVersion(platform, callback));
            }
            break;

            default:
            {
                IOSCheckAssetPackageVersion(platform, callback);
            }
            break;
            }
        }
        /// <summary>
        /// 加载ab
        /// </summary>
        /// <param name="path"></param>
        /// <param name="callback"></param>
        private void AsyncLoadAssetBundle(string path, Action <bool> callback)
        {
            //ab存储的是asset下的相对目录
            path = "assets/resource/runtime/" + path.ToLower();
            //寻找ab的后缀名
            var assetPath = GetExistPath(path);

            if (assetPath != null)
            {
                var res = manifest.Manifest.GetDirectDependencies(assetPath);
                //1.创建依赖加载队列
                Queue <string> loadQueue = new Queue <string>();
                foreach (var asset in res)
                {
                    //依赖队列需要加上resourcepath
                    var fullPath = Path.Combine(this.resourcePath, asset);
                    //判断是否已经加载过
                    if (assetbundleMap.ContainsKey(asset) == false)
                    {
                        loadQueue.Enqueue(fullPath);
                    }
                    else
                    {
                        assetbundleMap[asset].Use();
                    }
                }

                //2.加载主体
                if (assetbundleMap.ContainsKey(assetPath) == false)
                {
                    var fullPath = Path.Combine(this.resourcePath, assetPath);
                    loadQueue.Enqueue(fullPath);
                }

                //开始加载队列
                IEnumeratorTool.StartCoroutine(IEAsyncLoadAssetbundle(loadQueue, callback));
            }
            else
            {
                BDebug.LogError("没有该资源:" + path);
                //没有该资源
                callback(false);
            }
        }
Example #27
0
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="rootPath"></param>
        public void Init(string rootPath, RuntimePlatform platform = RuntimePlatform.Android)
        {
            //多热更切换,需要卸载
            if (this.AssetConfigLoder != null)
            {
                this.UnloadAllAsset();
            }

            //平台
            string platformPath = "";

            //1.设置加载路径
            if (Application.isEditor)
            {
                //editor下可以自行输入
                platformPath      = BApplication.GetPlatformPath(platform);
                firstArtDirectory = IPath.Combine(rootPath, platformPath, BResources.ART_ASSET_ROOT_PATH);
                secArtDirectory   = IPath.Combine(Application.streamingAssetsPath, platformPath, BResources.ART_ASSET_ROOT_PATH); //
            }
            else
            {
                //runtime只能使用当前平台
                platformPath      = BApplication.GetRuntimePlatformPath();
                firstArtDirectory = IPath.Combine(Application.persistentDataPath, platformPath, BResources.ART_ASSET_ROOT_PATH);
                secArtDirectory   = IPath.Combine(Application.streamingAssetsPath, platformPath, BResources.ART_ASSET_ROOT_PATH); //
                rootPath          = Application.persistentDataPath;
            }

            //2.寻址路径格式化
            firstArtDirectory = IPath.FormatPathOnRuntime(firstArtDirectory);
            secArtDirectory   = IPath.FormatPathOnRuntime(secArtDirectory);

            //3.加载ArtConfig
            this.AssetConfigLoder = GetAssetbundleConfigLoder(rootPath, platformPath);

            //开始异步任务刷新
            IEnumeratorTool.StartCoroutine(this.IE_LoadTaskUpdate());
            IEnumeratorTool.StartCoroutine(this.IE_UnLoadTaskUpdate());

            BDebug.Log($"【AssetBundleV2】 firstDir:{firstArtDirectory}", "red");
            BDebug.Log($"【AssetBundleV2】 secDir:{secArtDirectory}", "red");
        }
        /// <summary>
        /// 初始化DB
        /// </summary>
        /// <param name="str"></param>
        static public void Load(string root)
        {
            Connection?.Dispose();

            //先以外部传入的 作为 firstpath
            firstPath = IPath.Combine(root, BDUtils.GetPlatformPath(Application.platform) + "/Local.db");

            //firstpath不存在 或者 不支持io操作,
            //则默认情况生效,persistent为firstpath
            if (!File.Exists(firstPath))
            {
                //这里sqlite 如果不在firstPath下,就到Streamming下面拷贝到第一路径
                IEnumeratorTool.StartCoroutine(IE_LoadSqlite());
            }
            else
            {
                BDebug.Log("DB加载路径:" + firstPath, "red");
                Connection = new SQLiteConnection(firstPath, SQLiteOpenFlags.ReadWrite | SQLiteOpenFlags.Create);
            }
        }
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="path"></param>
 public AssetBundleManifestReference(string path)
 {
     if (Application.isEditor)
     {
         //这里开个同步接口 为了单元测试用
         if (File.Exists(path))
         {
             BDebug.Log("manifest加载成功!");
             var text = File.ReadAllText(path);
             this.Manifest = new ManifestConfig(text);
             OnLoaded?.Invoke();
             OnLoaded = null;
         }
     }
     else
     {
         //加载manifest
         IEnumeratorTool.StartCoroutine(IE_LoadConfig(path));
     }
 }
Example #30
0
        /// <summary>
        /// 加载ab
        /// </summary>
        /// <param name="path"></param>
        /// <param name="sucessCallback"></param>
        public void LoadAssetBundleAsync(string path, Action <bool> sucessCallback)
        {
            path = Path.Combine(LocalHotUpdateResPath, path);
            path = "file:///" + path;

            path = path.Replace("\\", "/");
            if (manifest.Manifest == null)
            {
                Debug.LogError("请先加载依赖文件!");
                return;
            }

            var res = manifest.Manifest.GetDirectDependencies(Path.GetFileName(path));
            //创建一个队列
            Queue <string> resQue = new Queue <string>();

            foreach (var r in res)
            {
                string _path = Path.GetDirectoryName(path) + "/" + Path.GetFileName(r);
                _path = _path.Replace("\\", "/");
                var key = Path.GetFileName(_path);
                if (AssetbundleMap.ContainsKey(key) == false)
                {
                    resQue.Enqueue(_path);
                }
                else
                {
                    AssetbundleMap[key].Use();
                }
            }

            if (AssetbundleMap.ContainsKey(Path.GetFileName(path)) == false)
            {
                resQue.Enqueue(path);
            }



            //开始加载队列
            IEnumeratorTool.StartCoroutine(IELoadAssetBundles(resQue, sucessCallback));
        }