예제 #1
0
        /// <summary>
        /// 关闭并卸载UI
        /// </summary>
        /// <param name="behaviourName"></param>
        public void CloseUI(string behaviourName)
        {
            IUIView behaviour = null;

            mAllUI.TryGetValue(behaviourName, out behaviour);

            if (null != behaviour)
            {
                OnPanelClose.InvokeGracefully(behaviour.PanelInfo);
                behaviour.Close();
                mAllUI.Remove(behaviourName);
            }
        }
예제 #2
0
        public bool CloseUI(int id)
        {
            int index = context.OpenUIIDs.FindIndex(x => x == id);

            if (index != -1)
            {
                context.OpenUIIDs.RemoveAt(index);

                if (context.UnitsState.TryGetValue(id, out UIUnitState unit))
                {
                    unit.PreState = unit.State;
                    unit.State    = eState.Close;
                }
            }
            else
            {
                Debug.LogError("試圖關閉未開啟的UI, ID is " + id);
                return(false);
            }

            view.Close(id);

            return(true);
        }