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

            RemoveUI(ui.TagID);
        }
Beispiel #2
0
        public static void SetUIHide(string TagID)
        {
            UI_Base ui = Instance.GetUIComponent <UI_Base>(TagID);

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

            if (ui == null)
            {
                return;
            }

            ui.OnOpen();
        }
Beispiel #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;
        }
Beispiel #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);
        }
Beispiel #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();//初始化
        }
Beispiel #7
0
        /// <summary>
        /// 隐藏UI
        /// </summary>
        /// <param name="TagID"></param>
        public void HideUI(string TagID)
        {
            UI_Base ui = GetUI(TagID);

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

            SetUI(ui);
        }
Beispiel #10
0
        public UI_Base GetUI(UI_Base @base)
        {
            var ui = UIs.Find(obj => obj.Equals(@base));

            return(ui);
        }
Beispiel #11
0
 public bool IsContains(UI_Base Base)
 {
     return(UIs.Contains(Base));
 }
        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();
        }