• 处理AB包的依赖问题(Unity)


    创建一个依赖关系的类 存放依赖项和被引用项 

    创建两个字典储存包 和 依赖关键  包名为key

    然后就是递归加载   内部先处理好包依赖 最后统一加载 

      public IEnumerator LoadAssetBundle(string bundleName)
            {
                if (!_DicABRelation.ContainsKey(bundleName)) {
                    _DicABRelation.Add(bundleName, new ABRelation(bundleName));
                }
                yield return AddBundleDepend(bundleName);
                if (!_DicSingleABLoaderCache.ContainsKey(bundleName))
                {
                    Debug.Log("加载包 : "+bundleName);
                    _CurrentSinglgABLoader = new SingleABLoader(bundleName, CompleteLoadAB);
                    _DicSingleABLoaderCache.Add(bundleName, _CurrentSinglgABLoader);
                    yield return _CurrentSinglgABLoader.LoadAssetBundle();
                }
    
            }
    
            // 添加这个包所依赖其它包的信息
            private IEnumerator AddBundleDepend(string bundleName) {
                var DependeInfo = ABManifestLoader.GetInstance().RetrivalDependce(bundleName);
                foreach (var dependBundleName in DependeInfo)
                {
                    _DicABRelation[bundleName].AddDependence(dependBundleName);
                    yield return AddBundleRefrence(bundleName,dependBundleName);
                }
            }
    
            // 添加这个包被引用的信息
            private IEnumerator AddBundleRefrence(string bundleName, string dependBundleName) {
                if (!_DicABRelation.ContainsKey(dependBundleName))
                {
                    _DicABRelation.Add(dependBundleName, new ABRelation(dependBundleName));
                    Debug.Log("添加包引用 : "+ dependBundleName);
    
                    yield return LoadAssetBundle(dependBundleName);
                }
                _DicABRelation[dependBundleName].AddReference(bundleName);
    
            }
    

      

  • 相关阅读:
    关于windows CE Platform Builder中模拟器的限制
    送给每天都用电脑的人
    用eVC4开发SmartPhone、Pocket PC程序之 开发工具下载、安装、配置
    在手机上显示图片
    如何禁止回车的使用
    弹出窗口的方法
    Request.Form同Request.querystring的区别.txt
    找前几天
    手机上可移动的图片
    httphandler是做什么的?
  • 原文地址:https://www.cnblogs.com/chenggg/p/10964729.html
Copyright © 2020-2023  润新知