Ejemplo n.º 1
0
        /// <summary>
        /// 打开UI窗体
        /// </summary>
        /// <param name="uiFormId">formId</param>
        /// <param name="userData"></param>
        internal void OpenUIForm(int uiFormId, object userData = null, BaseAction <UIFormBase> onOpen = null)
        {
            if (IsExists(uiFormId))
            {
                return;
            }

            //1.读表
            Sys_UIFormEntity entity = GameEntry.DataTable.DataTableManager.Sys_UIFormDBModel.Get(uiFormId);

            if (entity == null)
            {
                GameEntry.LogError(uiFormId + "对应的UI窗体不存在");
                return;
            }

            UIFormBase formBase = GameEntry.UI.Dequeue(uiFormId);

            if (formBase == null)
            {
                //TODO:异步加载UI需要时间 此处需要处理过滤加载中的UI

                string assetPath = string.Empty;
                switch (GameEntry.Localization.CurrLanguage)
                {
                case YouYouLanguage.Chinese:
                    assetPath = entity.AssetPath_Chinese;
                    break;

                case YouYouLanguage.English:
                    assetPath = entity.AssetPath_English;
                    break;
                }

                LoadUIAsset(assetPath, (ResourceEntity resourceEntity) =>
                {
                    GameObject uiObj = Object.Instantiate((Object)resourceEntity.Target) as GameObject;

                    //把克隆出来的资源 加入实例资源池
                    GameEntry.Pool.RegisterInstanceResource(uiObj.GetInstanceID(), resourceEntity);

                    uiObj.transform.SetParent(GameEntry.UI.GetUIGroup(entity.UIGroupId).Group);
                    uiObj.transform.localPosition = Vector3.zero;
                    uiObj.transform.localScale    = Vector3.one;

                    formBase = uiObj.GetComponent <UIFormBase>();
                    formBase.Init(uiFormId, entity.UIGroupId, entity.DisableUILayer == 1, entity.IsLock == 1, userData);
                    m_OpenUIFormList.AddLast(formBase);

                    if (onOpen != null)
                    {
                        onOpen(formBase);
                    }
                });
            }
            else
            {
                formBase.gameObject.SetActive(true);
                formBase.Open(userData);
                m_OpenUIFormList.AddLast(formBase);

                if (onOpen != null)
                {
                    onOpen(formBase);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 更新
        /// </summary>
        public void OnUpdate()
        {
            if (m_UnityWebRequest == null)
            {
                return;
            }

            if (m_TotalSize == 0)
            {
                m_TotalSize = 0;
                ulong.TryParse(m_UnityWebRequest.GetResponseHeader("Content-Length"), out m_TotalSize);
            }

            if (!m_UnityWebRequest.isDone)
            {
                if (m_CurrDownloadedSize < m_UnityWebRequest.downloadedBytes)
                {
                    m_CurrDownloadedSize = m_UnityWebRequest.downloadedBytes;

                    this.Sava(m_UnityWebRequest.downloadHandler.data);

                    if (m_OnUpdate != null)
                    {
                        m_OnUpdate(m_CurrFileUrl, m_CurrDownloadedSize, m_CurrDownloadedSize / (float)m_TotalSize);
                    }
                }
                return;
            }

            if (m_UnityWebRequest.isNetworkError)
            {
                GameEntry.LogError("下载失败url=>{0} error=>{1}", m_UnityWebRequest.url, m_UnityWebRequest.error);
                Reset();
            }
            else
            {
                m_CurrDownloadedSize = m_UnityWebRequest.downloadedBytes;
                this.Sava(m_UnityWebRequest.downloadHandler.data, true);

                if (m_OnUpdate != null)
                {
                    m_OnUpdate(m_CurrFileUrl, m_CurrDownloadedSize, m_CurrDownloadedSize / (float)m_TotalSize);
                }

                Reset();

                File.Move(m_DownloadLocalFilePath, m_DownloadLocalFilePath.Replace(".temp", ""));
                m_DownloadLocalFilePath = null;

                if (PlayerPrefs.HasKey(m_CurrFileUrl))
                {
                    PlayerPrefs.DeleteKey(m_CurrFileUrl);
                }

                //写入本地版本文件
                GameEntry.Resource.ResourceManager.SaveVersion(m_CurrAssetBundleInfo);

                if (m_OnComplete != null)
                {
                    m_OnComplete(m_CurrFileUrl, this);
                }
            }
        }
Ejemplo n.º 3
0
 public override void OnLeave()
 {
     base.OnLeave();
     GameEntry.Log(LogCategory.Procedure, "OnLeave ProcedureLogOn");
 }