示例#1
0
        public static Command ShowCmd(E_UIType _uiType, System.Action <BaseUI> listener, bool _isCloseOtherUIs, bool _createCanCall, params object[] _param)
        {
            Command cmd = new Command(Command.CmdType.Show, _uiType, _param);

            cmd.CreateCanCall   = _createCanCall;
            cmd.Listener        = listener;
            cmd.IsCloseOtherUIs = _isCloseOtherUIs;

            return(cmd);
        }
示例#2
0
        public BaseUI GetUIByType(E_UIType uiType)
        {
            //关闭其他ui
            if (_dicUI.ContainsKey(uiType))
            {
                return(_dicUI[uiType]);
            }

            return(null);
        }
示例#3
0
        public static Command ShowCmd_LUA(E_UIType _uiType, LuaFunction lua_fun, bool _isCloseOtherUIs, bool _createCanCall, params object[] _param)
        {
            Command cmd = new Command(Command.CmdType.Show, _uiType, _param);

            cmd.CreateCanCall   = _createCanCall;
            cmd.lua_fun         = lua_fun;
            cmd.IsCloseOtherUIs = _isCloseOtherUIs;

            return(cmd);
        }
示例#4
0
        public static Command CreateAndShowCmd_LUA(E_UIType uiType, System.Type type, LuaFunction lua_fun, bool isCloseOtherUIs, bool createCanCall, params object[] param)
        {
            Command cmd = new Command(Command.CmdType.CreateAndShow, uiType, param);

            cmd.lua_fun         = lua_fun;
            cmd.MonoType        = type;
            cmd.CreateCanCall   = createCanCall;
            cmd.IsCloseOtherUIs = isCloseOtherUIs;
            cmd.bLuaBehaviour   = true;
            return(cmd);
        }
示例#5
0
        public static Command CreateAndShowCmd(E_UIType uiType, System.Type type, System.Action <BaseUI> listener, bool isCloseOtherUIs, bool createCanCall, params object[] param)
        {
            Command cmd = new Command(Command.CmdType.CreateAndShow, uiType, param);

            cmd.Listener        = listener;
            cmd.MonoType        = type;
            cmd.CreateCanCall   = createCanCall;
            cmd.IsCloseOtherUIs = isCloseOtherUIs;
            cmd.bLuaBehaviour   = false;
            return(cmd);
        }
示例#6
0
        /// <summary>
        /// 给定view是否正在显示
        /// </summary>
        /// <param name="view"></param>
        /// <returns></returns>
        public bool IsViewShowing(E_UIType view)
        {
            int order = GetLargestOrder();

            if (uiCp.canvases.ContainsKey(view))
            {
                return(uiCp.canvases[view].sortingOrder == order);
            }

            return(false);
        }
示例#7
0
        private void AddUI(BaseUI ui)
        {
            E_UIType uiType = ui.GetUIType();

            if (_dicUI.ContainsKey(uiType))
            {
                _dicUI[uiType] = ui;
            }
            else
            {
                _dicUI.Add(uiType, ui);
            }
        }
示例#8
0
        /// <summary>
        /// Close view
        /// </summary>
        /// <param name="type"></param>
        public void CloseUI(E_UIType type)
        {
            int index = GetViewTypeIndex(type);

            if (index != -1)
            {
                var ui = GetUI(index);

                showSystem.CloseView(ui);
                RemoveUI(index);

                CheckCanvasUsable(index);
            }
        }
示例#9
0
        public GameObject GetCanvas(E_UIType type)
        {
            GameObject _canvasObj;

            if (uiCp.canvases.ContainsKey(type))
            {
                _canvasObj = uiCp.canvases[type].gameObject;
            }
            else
            {
                _canvasObj = new GameObject(type.ToString() + "_canvas");
                GameObject.DontDestroyOnLoad(_canvasObj);
                Canvas _canvas = _canvasObj.AddComponent <Canvas>();
                _canvas.renderMode   = RenderMode.ScreenSpaceCamera;
                _canvas.pixelPerfect = false;
                if (_canvas.worldCamera == null)
                {
                    _canvas.worldCamera = Camera.main;
                }

                // Set oreder, get largest order
                int _order = 0;
                switch (type)
                {
                case E_UIType.PopupUI:
                    _order = 100;
                    break;

                default:
                    _order = GetLargestOrder() + 1;
                    break;
                }

                _canvas.sortingOrder = _order;

                CanvasScaler _scaler = _canvasObj.AddComponent <CanvasScaler>();
                _scaler.uiScaleMode         = CanvasScaler.ScaleMode.ScaleWithScreenSize;
                _scaler.referenceResolution = new Vector2(Screen.width, Screen.height);
                _scaler.screenMatchMode     = CanvasScaler.ScreenMatchMode.Expand;

                _canvasObj.AddComponent <GraphicRaycaster>();
                uiCp.canvases.Add(type, _canvas);
            }

            return(_canvasObj);
        }
示例#10
0
        /// <summary>
        /// 得到最上曾的canvas
        /// </summary>
        /// <returns></returns>
        public GameObject GetUperCanvas(List <E_UIType> exceptType = null)
        {
            int      _order = -1;
            E_UIType index  = uiCp.canvases.Keys.First();

            foreach (var _c in uiCp.canvases.Keys)
            {
                if (uiCp.canvases[_c].sortingOrder > _order && (exceptType == null || exceptType.Contains(_c) == false))
                {
                    if (uiCp.canvases[_c].transform.childCount > 0)
                    {
                        index  = _c;
                        _order = uiCp.canvases[_c].sortingOrder;
                    }
                }
            }

            return(uiCp.canvases[index].gameObject);
        }
示例#11
0
        /// <summary>
        /// Open view with type
        /// </summary>
        public GameObject OpenUI(E_UIType type, bool singleton = false)
        {
            GameObject _view;

            // 重新排序
            ResetOrder();

            _view = CreateUI(type, singleton);

            // pop to front
            PopToFront(type);

            showSystem.ShowView(_view);

            uiCp.lastMainView = type;

            uiCp.openView = type;

            return(_view);
        }
示例#12
0
        GameObject CreateUI(E_UIType type, bool isSingleton = false)
        {
            int index = GetViewTypeIndex(type);

            if ((isSingleton && index == -1) || !isSingleton)
            {
                GameObject canvasObj = GetCanvas(type);

                // Instantiate
                // var prefab = poolSystem.Get((int)type);
                // if (prefab == null)
                // {
                //     prefab = Resources.Load<GameObject>(uiCp.UI_PATH + type.ToString());
                //     poolSystem.Push((int)type, prefab);
                // }
                // var ui = GameObject.Instantiate(prefab, canvasObj.transform);
                var ui = UISystemUtil.CreateUIFromPrefab(poolSystem,
                                                         (int)type,
                                                         uiCp.UI_PATH + type.ToString(),
                                                         canvasObj.transform);

                // Add to container
                if (index == -1)
                {
                    uiCp.views.Add(new Views(type, new GameObject[] { ui }));
                }
                else
                {
                    uiCp.views[index].uis.Add(ui);
                }

                index = uiCp.views.Count - 1;
            }

            return(GetUI(index));
        }
示例#13
0
 public void ShowUIAndCloseOthers_LUA(E_UIType uiType, LuaFunction func = null, params object[] param)
 {
     ShowUI_LUA(uiType, func, true, true, param);
     _layerCurrentIndex = 0;
 }
示例#14
0
 int GetViewTypeIndex(E_UIType type)
 {
     return(uiCp.views.FindIndex(v => v.uiType == type));
 }
示例#15
0
 public void DestroyUI(E_UIType uiType)
 {
     _listCmd.Add(Command.DestroyCmd(uiType));
 }
示例#16
0
 public void HideUI(E_UIType uiType)
 {
     _listCmd.Add(Command.HideCmd(uiType));
 }
示例#17
0
 public GameObject ReopenView(E_UIType type)
 {
     CloseUI(type);
     return(OpenUI(type));
 }
示例#18
0
 private Command(CmdType _cmdType, E_UIType _uiType, params object[] _params)
 {
     CommandType = _cmdType;
     UIType      = _uiType;
     Params      = _params;
 }
示例#19
0
        public static Command DestroyCmd(E_UIType _uiType)
        {
            Command cmd = new Command(Command.CmdType.Destroy, _uiType);

            return(cmd);
        }
示例#20
0
        public static Command HideCmd(E_UIType _uiType)
        {
            Command cmd = new Command(Command.CmdType.Hide, _uiType);

            return(cmd);
        }
示例#21
0
 /// <summary>
 /// 打开ui,并关闭其他所有
 /// </summary>
 /// <param name="uiType">UI类型</param>
 /// <param name="typeMono">绑定mono脚本类型</param>
 /// <param name="listener">回调监听</param>
 /// <param name="createCanCall">只是创建ui时是否回调</param>
 /// <param name="param">参数</param>
 public void ShowUIAndCloseOthers(E_UIType uiType, System.Type typeMono, System.Action <BaseUI> listener = null, bool createCanCall = false, params object[] param)
 {
     ShowUI(uiType, typeMono, listener, true, createCanCall = false, param);
     _layerCurrentIndex = 0;
 }
示例#22
0
        public static Command CreateCmd(System.Type _type, E_UIType _uiType, System.Action <BaseUI> _listener)
        {
            Command cmd = new Command(Command.CmdType.Create, _uiType, _type, _listener);

            return(cmd);
        }
示例#23
0
        public static Command CreateCmd_LUA(System.Type _type, E_UIType _uiType, LuaFunction _lua_fun)
        {
            Command cmd = new Command(Command.CmdType.Create, _uiType, _type, _lua_fun);

            return(cmd);
        }
示例#24
0
 public Views(E_UIType type, GameObject[] ui)
 {
     uiType = type;
     uis    = new List <GameObject>(ui);
 }
示例#25
0
 /// <summary>
 /// 创建ui,不显示
 /// </summary>
 /// <param name="uiType">User interface type.</param>
 /// <param name="type">Type.</param>
 /// <param name="listener">Listener.</param>
 public void CreateUI(E_UIType uiType, System.Type monoType, System.Action <BaseUI> listener)
 {
     _listCmd.Add(Command.CreateCmd(monoType, uiType, listener));
 }