Esempio n. 1
0
        public UI_Base ShowUI(String _name, params object[] _args)
        {
            UI_Base ui_obj = _getUIObject(_name, true);

            if (ui_obj == null)
            {
                return(null);
            }

            if (ui_obj.gameObject.activeSelf)
            {
                return(ui_obj);
            }

            if (ui_obj.Type == UIType.Window)
            {
                StartCoroutine(_showWindow(ui_obj, false, _args));
            }
            else if (ui_obj.Type == UIType.Dialog)
            {
                StartCoroutine(_showDialog(ui_obj, _args));
            }
            else
            {
                StartCoroutine(_showOtherUI(ui_obj, _args));
            }
            return(ui_obj);
        }
Esempio n. 2
0
        /// <summary>
        /// 创建一个UI
        /// </summary>
        /// <param name="_name"></param>
        /// <returns></returns>
        private UI_Base _createUIObject(String _name)
        {
            UnityEngine.Object prefab = null;
#if !GROOT_ASSETBUNDLE_SIMULATION && UNITY_EDITOR
            String path = String.Format("{0}/{1}.prefab", WeiqiApp.UI_PREFAB_ROOT_PATH, _name);
            prefab = AssetDatabase.LoadMainAssetAtPath(path);
            if (prefab == null)
            {
                Utility.Log.Error("[UIManager._create]ui: {0} 不存在!", path);
                return(null);
            }
#else
            Resource_Assetbundle bundle = ResourceManager.Instance.LoadAssetbundleSync(String.Concat("ui/", _name, ".ui"));
            if (bundle.Assetbundle == null)
            {
                Utility.Log.Error("[UIManager._create]ui: {0} 不存在!", _name);
                return(null);
            }
            prefab = bundle.Assetbundle.LoadAsset(_name);
            bundle.Unload(false);
            //prefab = ResourceManager.Instance.LoadUIObject( _name );
#endif
            GameObject ui_object = Instantiate(prefab) as GameObject;
            ui_object.SetActive(false);
            ui_object.name = _name;             //预制创建出来名字中会有(Clone)所以去掉

            // 放置ui到对应的层
            UI_Base ui_base = ui_object.GetComponent <UI_Base>();
            ui_object.transform.SetParent(m_layer_transforms[(Int32)ui_base.Layer], false);

            ui_base.OnLoaded();
            m_loaded_ui.Add(ui_base);
            return(ui_base);
        }
Esempio n. 3
0
        private IEnumerator _navigatorBack()
        {
            if (m_windows_name_stack.Count < 2)
            {
                Utility.Log.Exception("ui_win的Stack已经到底,不能再返回");
                yield break;
            }

            SetEventSystemEnable(false);

            // 先处理当前窗口的隐藏
            UI_Base current_win_obj = _getUIObject(m_windows_name_stack.Pop(), false);
            UI_Base next_win_obj    = _getUIObject(m_windows_name_stack.Peek(), true);

            Single exit_time_1 = current_win_obj.PreHide(next_win_obj);
            Single exit_time_2 = m_title_obj.PreHide(next_win_obj);
            Single exit_time   = exit_time_1 > exit_time_2 ? exit_time_1 : exit_time_2;

            current_win_obj.PlayExitAnimation();
            m_title_obj.PlayExitAnimation();

            if (m_dialog_name_list.Count == 0)
            {
                current_win_obj.OnFocusChanged(false);
            }

            yield return(new WaitForSeconds(exit_time));

            current_win_obj.gameObject.SetActive(false);
            m_title_obj.gameObject.SetActive(false);
            current_win_obj.OnHide(next_win_obj);
            m_title_obj.OnHide(next_win_obj);
            // 处理新窗口的显示

            next_win_obj.gameObject.SetActive(true);
            m_title_obj.gameObject.SetActive(true);
            // 打开窗口的参数暂时先不要
            Single entrance_time_1 = next_win_obj.PreShow(current_win_obj);
            Single entrance_time_2 = m_title_obj.PreShow(null, next_win_obj.GetTitleEntranceAnimationName(current_win_obj.name));

            Single entrance_time = entrance_time_1 > entrance_time_2 ? entrance_time_1 : entrance_time_2;

            next_win_obj.transform.SetAsLastSibling();
            m_title_obj.transform.SetAsLastSibling();
            next_win_obj.PlayEntranceAnimation();
            m_title_obj.PlayEntranceAnimation();
            m_current_window = next_win_obj;

            yield return(new WaitForSeconds(entrance_time));

            if (m_dialog_name_list.Count == 0)
            {
                next_win_obj.OnFocusChanged(true);
            }

            next_win_obj.OnShow(current_win_obj);
            m_title_obj.OnShow(null);
            SetEventSystemEnable(true);
        }
Esempio n. 4
0
 public override void OnShow(UI_Base _pre_ui, params object[] _args)
 {
     if (m_lua_functions[(Int32)LuaFunctionName.OnShow] == null)
     {
         return;
     }
     m_lua_functions[(Int32)LuaFunctionName.OnShow].call(_pre_ui == null ? String.Empty : _pre_ui.name, _args);
 }
Esempio n. 5
0
 /// <summary>
 /// 界面被隐藏时调用。
 /// <param name="_next_ui"></param>
 /// </summary>
 public override void OnHide(UI_Base _next_ui)
 {
     if (m_lua_functions[(Int32)LuaFunctionName.OnHide] == null)
     {
         return;
     }
     m_lua_functions[(Int32)LuaFunctionName.OnHide].call(_next_ui == null ? String.Empty : _next_ui.name);
 }
Esempio n. 6
0
        private IEnumerator _hideDialog(UI_Base _ui_dialog)
        {
            if (m_dialog_name_list.Count == 0)
            {
                Utility.Log.Warning("[UIManager._hideDialog]: 试图隐藏Dialog: {0}, 但dialog list 为空!", _ui_dialog.name);
                yield break;
            }
            // 处理dialog焦点
            if (m_dialog_name_list.Last.Value == _ui_dialog.name)
            {
                m_dialog_name_list.RemoveLast();
                if (m_dialog_name_list.Count > 0)
                {
                    UI_Base next_topmost_dialog = _getUIObject(m_dialog_name_list.Last.Value, false);
                    if (next_topmost_dialog != null)
                    {
                        next_topmost_dialog.OnFocusChanged(true);
                    }
                }
            }
            else
            {
                var target_node = m_dialog_name_list.Find(_ui_dialog.name);
                if (null == target_node)
                {
                    yield break;
                }
                m_dialog_name_list.Remove(target_node);
            }


            _ui_dialog.PlayExitAnimation();
            Single exit_time = _ui_dialog.PreHide(null);

            _ui_dialog.OnFocusChanged(false);
            if (exit_time > float.Epsilon)
            {
                yield return(new WaitForSeconds(exit_time));
            }

            //  处理windows焦点
            if (m_dialog_name_list.Count == 0 && m_windows_name_stack.Count != 0)
            {
                UI_Base ui_win = _getUIObject(m_windows_name_stack.Peek(), false);
                if (ui_win == null)
                {
                    Log.Error("[UIManager._hideDialog]: 最上层windows没有被显示?!");
                }
                else
                {
                    ui_win.OnFocusChanged(true);
                }
            }
            _ui_dialog.gameObject.SetActive(false);
            _ui_dialog.OnHide(null);
        }
Esempio n. 7
0
        /// <summary>
        /// 获取一个UIObject
        /// </summary>
        /// <param name="_name">UI名称</param>
        /// <param name="_create">如果没有获取到是否需要重新创建</param>
        /// <returns></returns>
        private UI_Base _getUIObject(String _name, Boolean _create)
        {
            UI_Base ui_object = m_loaded_ui.Find((v) => { return(v.gameObject.name == _name); });

            if (ui_object == null && _create)
            {
                ui_object = _createUIObject(_name);
            }
            return(ui_object);
        }
Esempio n. 8
0
        private IEnumerator _onReturnLobby(Int32 _idx)
        {
            if (m_windows_name_stack.Count == 0)
            {
                Log.Exception("[UIManager._onReturnLobby]: 返回到一个不存在的窗口!");
                yield break;
            }

            if (_idx < 0)
            {
                Int32 tmp = -_idx - 1;
                for (Int32 i = 0; i < tmp; ++i)
                {
                    m_windows_name_stack.Pop();
                }
            }
            else
            {
                if (m_windows_name_stack.Count < _idx)
                {
                    Utility.Log.Exception("[UIManager._onReturnLobby]: 返回窗口,栈idx 无效.");
                    yield break;
                }
                Int32 tmp = m_windows_name_stack.Count - _idx;
                for (Int32 i = 0; i < tmp; ++i)
                {
                    m_windows_name_stack.Pop();
                }
            }
            UI_Base ui_object       = _getUIObject(m_windows_name_stack.Peek(), true);
            Single  entrance_time_1 = ui_object.PreShow(null);
            Single  entrance_time_2 = m_title_obj.PreShow(null, ui_object.GetTitleEntranceAnimationName(ui_object.name));

            Single entrance_time = entrance_time_1 > entrance_time_2 ? entrance_time_1 : entrance_time_2;

            ui_object.gameObject.SetActive(true);
            m_title_obj.gameObject.SetActive(true);
            m_current_window = ui_object;
            ui_object.transform.SetAsLastSibling();
            m_title_obj.transform.SetAsLastSibling();
            ui_object.PlayEntranceAnimation();
            m_title_obj.PlayEntranceAnimation();

            yield return(entrance_time);

            if (m_dialog_name_list.Count == 0)
            {
                ui_object.OnFocusChanged(true);
            }
            ui_object.OnFocusChanged(true);

            ui_object.OnShow(null);
            m_title_obj.OnShow(null);
        }
Esempio n. 9
0
        public void HideUI(String _name)
        {
            UI_Base obj = _getUIObject(_name, false);

            if (obj == null)
            {
                Utility.Log.Verbose("HideUI: 需要隐藏的界面 [{0}]不存在!", _name);
                return;
            }
            HideUI(obj);
        }
Esempio n. 10
0
        public UI_Base ShowBackGroundUI(String _name, params object[] _args)
        {
            UI_Base ui_obj = _getUIObject(_name, true);

            if (ui_obj == null)
            {
                return(null);
            }
            ui_obj.PreShow(null, _args);
            ui_obj.gameObject.SetActive(true);
            return(ui_obj);
        }
Esempio n. 11
0
        private IEnumerator _hideOtherUI(UI_Base _ui_object)
        {
            _ui_object.PlayExitAnimation();
            Single exit_time = _ui_object.PreHide(null);

            if (exit_time > float.Epsilon)
            {
                yield return(new WaitForSeconds(exit_time));
            }
            _ui_object.gameObject.SetActive(false);
            _ui_object.OnHide(null);
        }
Esempio n. 12
0
        /// <summary>
        /// 界面被即将隐藏, 调用退出动画之前
        /// </summary>
        /// <returns>PreHide到OnHide调用的间隔时间</returns>
        public override Single PreHide(UI_Base _next_ui)
        {
            if (m_lua_functions[(Int32)LuaFunctionName.PreHide] == null)
            {
                return(m_exit_anim_time);
            }
            object re = m_lua_functions[(Int32)LuaFunctionName.PreHide].call(_next_ui == null ? String.Empty : _next_ui.name);

            if (re == null)
            {
                return(m_exit_anim_time);
            }
            return((Single)re);
        }
Esempio n. 13
0
        public override float PreShow(UI_Base _pre_ui, params object[] _args)
        {
            if (m_lua_functions[(Int32)LuaFunctionName.PreShow] == null)
            {
                return(m_entrance_anim_time);
            }
            object re = m_lua_functions[(Int32)LuaFunctionName.PreShow].call(_pre_ui == null ? "" : _pre_ui.name, _args);

            if (re == null)
            {
                return(m_entrance_anim_time);
            }
            return((Single)re);
        }
Esempio n. 14
0
        private IEnumerator _showOtherUI(UI_Base _ui_object, params object[] _args)
        {
            _ui_object.gameObject.SetActive(true);
            Single entrance_time = _ui_object.PreShow(null, _args);

            _ui_object.transform.SetAsLastSibling();
            _ui_object.PlayEntranceAnimation();

            if (entrance_time > float.Epsilon)
            {
                yield return(new WaitForSeconds(entrance_time));
            }
            _ui_object.OnShow(null);
        }
Esempio n. 15
0
 public void HideUI(UI_Base _ui_object)
 {
     if (_ui_object.Type == UIType.Window)
     {
         Utility.Log.Error("HideUI: Window不能使用HideUI接口!");
         return;
     }
     else if (_ui_object.Type == UIType.Dialog)
     {
         StartCoroutine(_hideDialog(_ui_object));
     }
     else
     {
         StartCoroutine(_hideOtherUI(_ui_object));
     }
 }
Esempio n. 16
0
 /// <summary>
 /// 反初始化
 /// </summary>
 public void Uninitialize()
 {
     foreach (UI_Base ui_base in m_loaded_ui)
     {
         if (ui_base.gameObject.activeSelf)
         {
             ui_base.OnHide(null);
         }
         ui_base.OnUnload();
         DestroyImmediate(ui_base.gameObject, true);
     }
     m_title_obj = null;
     m_loaded_ui.Clear();
     m_current_window = null;
     m_windows_name_stack.Clear();
 }
Esempio n. 17
0
        /// <summary>
        ///     显示Windows并且重建堆栈
        /// </summary>
        /// <param name="_name">Window名称</param>
        /// <param name="_args">额外参数</param>
        /// <returns></returns>
        public UI_Base ShowWindowWithStackRebuild(String _name, params object[] _args)
        {
            UI_Base ui_win_obj = _getUIObject(_name, true);

            if (ui_win_obj == null)
            {
                Log.Error("[UIManager.ShowWindowWithStackRebuild]: 目标UI: [0]不存在!", _name);
                return(null);
            }

            if (ui_win_obj.Type != UIType.Window)
            {
                Log.Error("[UIManager.ShowWindowWithStackRebuild]: 不是Window: {0}", _name);
                return(null);
            }

            StartCoroutine(_showWindow(ui_win_obj, true, _args));
            return(ui_win_obj);
        }
Esempio n. 18
0
        private IEnumerator _showDialog(UI_Base _ui_dialog, params object[] _args)
        {
            if (m_dialog_name_list.Count == 0)
            {
                if (m_windows_name_stack.Count > 0)
                {
                    UI_Base ui_win = _getUIObject(m_windows_name_stack.Peek(), false);
                    if (ui_win != null)
                    {
                        ui_win.OnFocusChanged(false);
                    }
                }
            }
            else
            {
                UI_Base ui_dialog = _getUIObject(m_dialog_name_list.Last.Value, false);
                if (ui_dialog != null)
                {
                    ui_dialog.OnFocusChanged(false);
                }
            }
            _ui_dialog.gameObject.SetActive(true);
            Single entrance_time = _ui_dialog.PreShow(null, _args);

            _ui_dialog.transform.SetAsLastSibling();
            _ui_dialog.PlayEntranceAnimation();
            m_dialog_name_list.AddLast(_ui_dialog.name);

            if (entrance_time > float.Epsilon)
            {
                yield return(new WaitForSeconds(entrance_time));
            }

            _ui_dialog.OnFocusChanged(true);
            _ui_dialog.OnShow(null);
            yield return(new WaitForEndOfFrame());
            //SignalSystem.FireSignal( SignalId.UICore_OnLobbyUIShowed, _ui_dialog );
        }
Esempio n. 19
0
 /// <summary>
 /// 界面被即将隐藏, 调用退出动画之前
 /// </summary>
 /// <returns>PreHide到OnHide调用的间隔时间</returns>
 public virtual Single PreHide(UI_Base _next_ui)
 {
     return(m_exit_anim_time);
 }
Esempio n. 20
0
 /// <summary>
 /// 界面被显示时调用。
 /// <param name="_args">其他界面调用时给过来的参数,和传递给PreShow的参数相同</param>
 /// </summary>
 public virtual void OnShow(UI_Base _pre_ui, params object[] _args)
 {
 }
Esempio n. 21
0
        private IEnumerator _showWindow(UI_Base _ui_object, Boolean _rebuild_stack, params object[] _args)
        {
            SetEventSystemEnable(false);
            UI_Base current_win_obj = null;

            if (m_windows_name_stack.Count != 0)
            {
                current_win_obj = _getUIObject(m_windows_name_stack.Peek(), false);

                if (current_win_obj != null)
                {
                    Single exit_time_1 = current_win_obj.PreHide(_ui_object);
                    Single exit_time_2 = m_title_obj.PreHide(_ui_object);

                    current_win_obj.PlayExitAnimation();
                    m_title_obj.PlayExitAnimation();

                    if (m_dialog_name_list.Count == 0)
                    {
                        current_win_obj.OnFocusChanged(false);
                    }

                    yield return(new WaitForSeconds(exit_time_1 > exit_time_2 ? exit_time_1 : exit_time_2));

                    current_win_obj.gameObject.SetActive(false);
                    m_title_obj.gameObject.SetActive(false);
                    current_win_obj.OnHide(_ui_object);
                    m_title_obj.OnHide(_ui_object);
                }
            }

            // 重建堆栈
            if (_rebuild_stack)
            {
                _rebuidStack(_ui_object.name);
            }


            _ui_object.gameObject.SetActive(true);
            m_title_obj.gameObject.SetActive(true);
            Single entrance_time_1 = _ui_object.PreShow(current_win_obj, _args);
            Single entrance_time_2 = m_title_obj.PreShow(
                null,
                _args,
                _ui_object.GetTitleEntranceAnimationName(current_win_obj != null ? current_win_obj.name : String.Empty));

            //Single entrance_time = entrance_time_1 > entrance_time_2 ? entrance_time_1 : entrance_time_2;

            _ui_object.transform.SetAsLastSibling();
            m_title_obj.transform.SetAsLastSibling();
            _ui_object.PlayEntranceAnimation();

            if (entrance_time_1 > entrance_time_2)
            {
                yield return(new WaitForSeconds(entrance_time_1 - entrance_time_2));
            }

            m_title_obj.PlayEntranceAnimation();

            m_windows_name_stack.Push(_ui_object.name);
            m_current_window = _ui_object;

            yield return(new WaitForSeconds(entrance_time_1 < entrance_time_2 ? entrance_time_1 : entrance_time_2));

            if (m_dialog_name_list.Count == 0)
            {
                _ui_object.OnFocusChanged(true);
            }

            _ui_object.OnShow(current_win_obj, _args);
            m_title_obj.OnShow(null);
            yield return(new WaitForEndOfFrame());

            SetEventSystemEnable(true);
            //SignalSystem.FireSignal( SignalId.UICore_OnLobbyUIShowed, _ui_object );
        }
Esempio n. 22
0
 /// <summary>
 /// 界面被隐藏时调用。
 /// <param name="_next_ui"></param>
 /// </summary>
 public virtual void OnHide(UI_Base _next_ui)
 {
 }
Esempio n. 23
0
 /// <summary>
 /// 界面被即将显示, 调用进入动画之前
 /// </summary>
 /// <param name="_pre_ui">之前被打开的界面</param>
 /// <param name="_args">其他界面调用时给过来的参数列表, 和传递给OnShow的参数相同</param>
 /// <returns>PreShow到OnShow调用的间隔时间</returns>
 public virtual Single PreShow(UI_Base _pre_ui, params object[] _args)
 {
     return(m_entrance_anim_time);
 }
Esempio n. 24
0
 /// <summary>
 /// 创建标题栏这个特殊的存在
 /// </summary>
 public void CreateTitle()
 {
     m_title_obj = ShowUI("ui_title");
 }