Пример #1
0
        public IEnumerator LoadAssetBundle(string sceneName, string abName, ABLoadComplete abLoadComplete)
        {
            // 参数检查
            if (string.IsNullOrEmpty(sceneName) || string.IsNullOrEmpty(abName))
            {
                Debug.LogError(GetType() + "/LoadAssetBundle()/sceneName or abName == null,请检查!");
                yield return(null);
            }

            // 等待Manifest文件加载完成
            while (!ABManifestLoader.Instance.IsLoaded)
            {
                yield return(null);
            }
            manifest = ABManifestLoader.Instance.GetABManifest();
            if (manifest == null)
            {
                Debug.LogError(GetType() + "/LoadAssetBundle()/manifest == null,请检查!");
                yield return(null);
            }

            // 加入当前场景
            if (!multiABMgrDict.ContainsKey(sceneName))
            {
                MultiABMgr multiABMgr = new MultiABMgr(sceneName, abName, abLoadComplete);
                multiABMgrDict.Add(sceneName, multiABMgr);
            }

            // 调用下一层(多包管理)
            MultiABMgr tempMultiABMgr = multiABMgrDict[sceneName];

            if (tempMultiABMgr == null)
            {
                Debug.LogError(GetType() + "/LoadAssetBundle()/tempMultiABMgr == null,请检查!");
            }

            yield return(tempMultiABMgr.LoadAssetBundle(abName));
        }