Пример #1
0
        /// <summary>
        /// 移除UI对象
        /// </summary>
        /// <param name="ui"></param>
        public void RemoveUI(UI_Base ui)
        {
            if (ui == null)
            {
                return;
            }

            RemoveUI(ui.TagID);
        }
Пример #2
0
        public static void SetUIHide(string TagID)
        {
            UI_Base ui = Instance.GetUIComponent <UI_Base>(TagID);

            if (ui == null)
            {
                return;
            }
            ui.OnClose();
        }
Пример #3
0
        public static void SetUIShow(string TagID)
        {
            UI_Base ui = Instance.GetUIComponent <UI_Base>(TagID);

            if (ui == null)
            {
                return;
            }

            ui.OnOpen();
        }
Пример #4
0
        /// <summary>
        /// 设置UI
        /// </summary>
        /// <param name="ui"></param>
        public void SetUI(UI_Base ui)
        {
            if (CurrentUI == ui)
            {
                return;
            }

            if (CurrentUI != null)
            {
                CurrentUI.OnClose();
            }

            CurrentUI = ui;
        }
Пример #5
0
        /// <summary>
        /// 添加UI
        /// </summary>
        /// <param name="ui"></param>
        /// <param name="position"></param>
        public void AddUI(UI_Base ui, Vector3 position)
        {
            if (ui.type == UIType.Canvas)
            {
                ui.transform.SetParent(Canvas.transform);
            }
            else
            {
                ui.transform.SetParent(SpriteRenderer.transform);
            }

            ui.transform.localPosition = position;
            ui.transform.localScale    = Vector3.one;

            AddUI(ui);
        }
Пример #6
0
        /// <summary>
        /// 添加UI
        /// </summary>
        /// <param name="ui"></param>
        public void AddUI(UI_Base ui)
        {
            if (UIs == null)
            {
                UIs = new List <UI_Base>();
            }

            if (!IsContains(ui))
            {
                UIs.Add(ui);
            }

            if (ui.IsShow)
            {
                ui.OnOpen();
            }
            else
            {
                ui.OnClose();//默认关闭处理
            }
            //ui.OnInitialize();//初始化
        }
Пример #7
0
        /// <summary>
        /// 隐藏UI
        /// </summary>
        /// <param name="TagID"></param>
        public void HideUI(string TagID)
        {
            UI_Base ui = GetUI(TagID);

            ui.OnClose();
        }
Пример #8
0
 /// <summary>
 /// 添加UI界面到栈中
 /// </summary>
 /// <param name="mainInterface"></param>
 public static void AddUIToStack(UI_Base mainInterface)
 {
     Instance.mainInterfaces.Push(mainInterface);
 }
Пример #9
0
        /// <summary>
        /// 设置当前UI
        /// </summary>
        /// <param name="TagID"></param>
        public void SetUI(string TagID)
        {
            UI_Base ui = GetUI(TagID);

            SetUI(ui);
        }
Пример #10
0
        public UI_Base GetUI(UI_Base @base)
        {
            var ui = UIs.Find(obj => obj.Equals(@base));

            return(ui);
        }
Пример #11
0
 public bool IsContains(UI_Base Base)
 {
     return(UIs.Contains(Base));
 }
Пример #12
0
        private void BaseGUI(UI_Base ui)
        {
            GUILayout.BeginHorizontal();

            if (manager.IsContains(ui))
            {
                if (GUILayout.Button("从Manager移除", GUILayout.Width(120), GUILayout.Height(20)))
                {
                    manager.RemoveUI(ui);
                }
            }
            else
            {
                if (GUILayout.Button(new GUIContent("加入Manager", "点击之后,加入到Manager下"), GUILayout.Width(120), GUILayout.Height(20)))
                {
                    manager.AddUI(ui, Vector3.zero);
                }
            }

            if (GUILayout.Button(ui.name, GUILayout.Width(100), GUILayout.Height(20)))
            {
                Selection.activeGameObject = ui.gameObject;
            }

            ui.TagID = EditorGUILayout.TextField("", ui.TagID, GUILayout.Width(100), GUILayout.Height(20));
            ui.type  = (UIType)EditorGUILayout.EnumPopup("", ui.type, GUILayout.Width(100), GUILayout.Height(20));

            if (ui.gameObject.activeSelf)
            {
                if (GUILayout.Button("隐藏", GUILayout.Width(100), GUILayout.Height(20)))
                {
                    ui.gameObject.SetActive(false);
                }
            }
            else
            {
                if (GUILayout.Button("显示", GUILayout.Width(100), GUILayout.Height(20)))
                {
                    ui.gameObject.SetActive(true);
                }
            }

            GUILayout.Box(ui.GetType().ToString(), GUILayout.Width(300), GUILayout.Height(20));

            switch (ui.type)
            {
            case UIType.Canvas:

                if (ui.transform.parent == manager.Canvas.transform)
                {
                    break;
                }
                ui.transform.SetParent(manager.Canvas.transform);
                ui.transform.localPosition = Vector3.zero;

                break;

            case UIType.SpriteRender:
                if (ui.transform.parent == manager.SpriteRenderer.transform)
                {
                    break;
                }
                ui.transform.SetParent(manager.SpriteRenderer.transform);
                ui.transform.localPosition = Vector3.zero;
                break;

            default:
                break;
            }

            GUILayout.EndHorizontal();
        }