示例#1
0
        public IEnumerator Init(Action finish = null)
        {
            m_isInitialized    = false;
            m_nowLoadTaskCount = 0;
            m_maxLoadTaskCount = 10;

            if (null == ABReferenceMap)
            {
                ABReferenceMap = new Dictionary <string, ABReference>();
            }

            if (null != ABVersion.CurVersionInfo && ABVersion.CurVersionInfo.IsValid)
            {
                // 首包
                yield return(LauncherEngine.Instance.StartCoroutine(ABVersion.OriginalVersionInfo.ParseVersionListByWWW()));

                yield return(LauncherEngine.Instance.StartCoroutine(ABVersion.OriginalVersionInfo.ParseNatvieListByWWW()));

                // 清单文件
                bool   fromNativePath   = true;
                string manifestFilePath = ABVersion.CurVersionInfo.GetABFullPath(ABHelper.ManifestFileName, ref fromNativePath);
                if (!string.IsNullOrEmpty(manifestFilePath))
                {
                    if (fromNativePath)
                    {
                        WWW www = Application.platform == RuntimePlatform.Android ? new WWW(manifestFilePath) : new WWW("file://" + manifestFilePath);
                        yield return(www);

                        ABManifest = ABHelper.ReadManifestFileByBytes(www.bytes);
                    }
                    else
                    {
                        ABManifest = ABHelper.ReadManifestFileByPath(manifestFilePath);
                    }
                }
            }
            if (null != ABManifest)
            {
                m_isInitialized = true;
            }
            // 初始化完成,可进行后续操作
            if (null != finish)
            {
                Debug.Log("<color=#20F856>AB初始化完毕</color>");
                finish();
            }
        }