Пример #1
0
        public GameObject AddChild(GameObject parent, EUIType name)
        {
            GameObject go = GameObject.Instantiate(Resources.Load <GameObject>("View/" + _UIPathDict[name])) as GameObject;

            go.transform.SetParent(parent.transform, false);
            return(go);
        }
Пример #2
0
        public static Type GetUIType(this EUIType uiType)
        {
            switch (uiType)
            {
            case EUIType.Image: return(typeof(Image));

            case EUIType.RawImage: return(typeof(RawImage));

            case EUIType.Text: return(typeof(Text));

            case EUIType.Selectable: return(typeof(Selectable));

            case EUIType.Button: return(typeof(Button));

            case EUIType.Toggle: return(typeof(Toggle));

            case EUIType.Slider: return(typeof(Slider));

            case EUIType.Scrollbar: return(typeof(Scrollbar));

            case EUIType.Dropdown: return(typeof(Dropdown));

            case EUIType.InputField: return(typeof(InputField));

            case EUIType.ScrollRect: return(typeof(ScrollRect));

            case EUIType.Custom: return(typeof(ISearchableComponent));

            default: return(null);
            }
        }
Пример #3
0
        BaseUI FindLastUI <T>(EUIType type)
        {
            BaseUI ui = null;
            var    t  = typeof(T);

            if (type == EUIType.FullScreen)
            {
                ui = _OpenedFullScreenUI.FindLast((BaseUI tempUI) => tempUI.GetType() == t);
            }
            else if (type == EUIType.Coexisting)
            {
                if (CurFullScreenUI != null && _CoexistingUI.ContainsKey(CurFullScreenUI))
                {
                    ui = _CoexistingUI[CurFullScreenUI].FindLast((BaseUI tempUI) => tempUI.GetType() == t);
                }
            }
            else if (type == EUIType.Independent)
            {
                ui = _IndependentUI.FindLast((BaseUI tempUI) => tempUI.GetType() == t);
            }
            else if (type == EUIType.Resident)
            {
                ui = _ResidentUI.FindLast((BaseUI tempUI) => tempUI.GetType() == t);
            }
            return(ui);
        }
Пример #4
0
        /// <summary>
        /// 对界面进行压栈
        /// </summary>
        /// <typeparam name="T">界面的类型</typeparam>
        /// <param name="uiType">界面对应的uiType</param>
        /// <param name="param">界面对应的压栈参数</param>
        public void PushState <T>(EUIType uiType, object param = null) where T : BaseState
        {
            GameObject go = UIManager.GetInstance().GetSingleUI(uiType);

            go.GetComponent <BaseState>().UIType = uiType;
            PushState <T>(go, param);
        }
Пример #5
0
        public ColorGroup(ColorGroup colorGroup)
        {
            instanceId  = Guid.NewGuid();
            this.name   = colorGroup.name + "_copy";
            colorList   = new List <NamedColor>();
            effectors   = new List <Modifier>();
            descendants = new List <ColorGroupDescendant>();

            this.uiMask = colorGroup.uiMask;

            foreach (NamedColor nc in colorGroup.colorList)
            {
                colorList.Add(new NamedColor(nc));
            }

            foreach (Modifier effector in colorGroup.effectors)
            {
                effectors.Add(effector);
            }

            foreach (ColorGroupDescendant cgd in colorGroup.descendants)
            {
                descendants.Add(new ColorGroupDescendant(cgd));
            }
        }
Пример #6
0
        BaseUI FindLastIdenticalLayerUI(EUIType type, EUILayer layer)
        {
            BaseUI ui = null;

            if (type == EUIType.FullScreen)
            {
                ui = _OpenedFullScreenUI.FindLast((BaseUI tempUI) => tempUI._NaviData._Layer == layer);
            }
            else if (type == EUIType.Coexisting)
            {
                if (CurFullScreenUI != null && _CoexistingUI.ContainsKey(CurFullScreenUI))
                {
                    ui = _CoexistingUI[CurFullScreenUI].FindLast((BaseUI tempUI) => tempUI._NaviData._Layer == layer);
                }
            }
            else if (type == EUIType.Independent)
            {
                ui = _IndependentUI.FindLast((BaseUI tempUI) => tempUI._NaviData._Layer == layer);
            }
            else if (type == EUIType.Resident)
            {
                ui = _ResidentUI.FindLast((BaseUI tempUI) => tempUI._NaviData._Layer == layer);
            }
            return(ui);
        }
Пример #7
0
        protected void AddBubbleFrame(ChatDataItem chatDataItem)
        {
            EUIType    uiType      = (chatDataItem.sendUserId == GlobalUser.GetInstance().UserId) ? EUIType.PersonalChatBubbleFrame : EUIType.FriendChatBubbleFrame;
            GameObject bubbleFrame = UIManager.GetInstance().AddChild(_gridChatBubble.gameObject, uiType);

            bubbleFrame.GetComponent <ChatBubbleFrame>().Show(chatDataItem);
            _chatBubbleList.Add(bubbleFrame.GetComponent <ChatBubbleFrame>());
        }
Пример #8
0
    //  DealLuaObject(string uiPath, string luaPath, EUIType eType, bool useBack, EUICanvas canvas, bool isAutoReset, bool preLoad = false)

    public UIPreLoad(string uiPath, EUIType eType, bool useBack, EUICanvas canvas, bool isAutoReset, bool preLoad = false)
    {
        this.uiPath      = uiPath;
        this.eType       = eType;
        this.useBack     = useBack;
        this.canvas      = canvas;
        this.isAutoReset = isAutoReset;
        this.preLoad     = preLoad;
    }
 // 在此初始化参数
 protected override void OnCreate()
 {
     uitype  = (EUIType)Utility.ToEnumInt(parameters["uitype"]);
     rect    = Utility.ToRect(missionVars, parameters["rect"]);
     anchor  = (EUIAnchor)Utility.ToEnumInt(parameters["anchor"]);
     uitext  = Utility.ToText(missionVars, parameters["uitext"]);
     uistyle = (EUIStyle)Utility.ToEnumInt(parameters["uistyle"]);
     uievent = Utility.ToVarname(parameters["uievent"]);
 }
Пример #10
0
        public void DestroySingleUI(EUIType name)
        {
            if (_UIDict.ContainsKey(name) == false)
            {
                return;
            }

            GameObject.Destroy(_UIDict[name]);
            _UIDict.Remove(name);
        }
Пример #11
0
    public GameObject OpenUI(EUIType UIType)
    {
        string name = null;

        switch (UIType)
        {
        case EUIType.BattleWidget:
            name = "UI/Battle/BattleWidget";
            break;
        }

        return(CResourceMgr.LoadUI(name));
    }
Пример #12
0
        public void RefreshChildren(GameObject parent, EUIType name, int count, float childHeight, bool isVertical)
        {
            RefreshChildren(parent, name, count);

            Vector2 originalSize = parent.GetComponent <RectTransform>().sizeDelta;

            if (isVertical)
            {
                parent.GetComponent <RectTransform>().sizeDelta = new Vector2(originalSize.x, childHeight * count);
            }
            else
            {
                parent.GetComponent <RectTransform>().sizeDelta = new Vector2(childHeight * count, originalSize.y);
            }
        }
Пример #13
0
        public GameObject GetSingleUI(EUIType name)
        {
            if (_UIPathDict.ContainsKey(name) == false)
            {
                return(null);
            }

            if (_UIDict.ContainsKey(name) == false)
            {
                GameObject go = GameObject.Instantiate(Resources.Load <GameObject>("View/" + _UIPathDict[name])) as GameObject;
                go.transform.SetParent(_canvas, false);
                go.name = name.ToString();
                _UIDict.Add(name, go);
                return(go);
            }
            return(_UIDict[name]);
        }
Пример #14
0
 public void RefreshChildren(GameObject parent, EUIType name, int count)
 {
     if (parent.transform.childCount > count)
     {
         for (int i = count; i < parent.transform.childCount; i++)
         {
             GameObject.Destroy(parent.transform.GetChild(i).gameObject);
         }
     }
     else
     {
         for (int i = parent.transform.childCount; i < count; i++)
         {
             AddChild(parent, name);
         }
     }
 }
Пример #15
0
        private void OnColorModeSelected()
        {
            if (!EditMode)
            {
                elementsRListSP = EditorGUILayout.BeginScrollView(elementsRListSP);
                elementsRList.DoLayoutList();
                EditorGUILayout.EndScrollView();
                return;
            }
            GUILayout.BeginHorizontal();
            StylesUI.LeftColumn.fixedWidth = Mathf.Clamp(position.width * 0.3f, 50f, 300f);
            GUILayout.BeginVertical(StylesUI.LeftColumn);
            elementsRListSP = EditorGUILayout.BeginScrollView(elementsRListSP);
            elementsRList.DoLayoutList();
            EditorGUILayout.EndScrollView();
            GUILayout.EndVertical();
            if (!EditMode)
            {
                return;
            }
            GUILayout.BeginVertical();
            if (elementsRList.index != -1 && SelectedCG != null)
            {
                GUILayout.Space(15f);
                GUILayout.BeginVertical("Box");
                GUILayout.Label("Element " + SelectedCG.name, StylesUI.TitleLabel);
                GUILayout.Space(10f);
                GUILayout.BeginHorizontal();
                SelectedCG.name = EditorGUILayout.TextField("Name", SelectedCG.name);
                if (EditorHelper.DrawButton(false, StylesUI.Icon, () =>
                {
                    return(GUILayout.Button(StylesUI.DuplicateButton, StylesUI.IconButton));
                }))
                {
                    Theme.colors.Add(new ColorGroup(SelectedCG));
                    UpdateColorNames();
                }
                GUILayout.EndHorizontal();

                GUILayout.Space(5f);
                GUILayout.Label("Filter Properties", StylesUI.TitleLabel);
                GUILayout.Space(5f);
                // #if UNITY_2017_4_OR_NEWER
                EUIType t = (EUIType)EditorGUILayout.EnumFlagsField("Type", (EUIType)SelectedCG.uiMask, StylesUI.Popup);
                if (t != SelectedCG.uiMask)
                {
                    SelectedCG.uiMask = t;
                    UpdateColors(SelectedCG);
                }
                // #endif
                GUILayout.BeginHorizontal();
                SelectedCG.tag = EditorGUILayout.TagField("Tag", SelectedCG.tag, StylesUI.Popup);
                if (EditorHelper.DrawButton(false, StylesUI.Icon, () =>
                {
                    return(GUILayout.Button(StylesUI.DeleteTextButton, StylesUI.IconButton));
                }))
                {
                    SelectedCG.tag = "";
                }
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                SelectedCG.regex = EditorGUILayout.TextField("Regex", SelectedCG.regex);
                if (EditorHelper.DrawButton(false, StylesUI.Icon, () =>
                {
                    return(GUILayout.Button(StylesUI.HelpButton, StylesUI.IconButton));
                }))
                {
                    Application.OpenURL("https://msdn.microsoft.com/en-us/library/az24scfc(v=vs.110).aspx");
                }
                GUILayout.EndHorizontal();
                GUILayout.Space(10f);
                GUILayout.EndVertical();

                GUILayout.Space(10f);

                elementRListSP = EditorGUILayout.BeginScrollView(elementRListSP);

                if (colorsList != null)
                {
                    colorsList.DoLayoutList();
                    GUILayout.Space(15f);
                }

                if (palleteList != null)
                {
                    palleteList.DoLayoutList();
                    GUILayout.Space(15f);
                }

                if (elementModifierList != null)
                {
                    elementModifierList.DoLayoutList();
                    GUILayout.Space(15f);
                }

                if (elementDescendantsRList != null)
                {
                    elementDescendantsRList.DoLayoutList();
                }

                EditorGUILayout.EndScrollView();

                GUILayout.BeginHorizontal();
                GameObject prefab = null;
                if (Selection.activeGameObject)
                {
                    #if UNITY_2018_3_OR_NEWER
                    prefab = PrefabUtility.GetOutermostPrefabInstanceRoot(Selection.activeGameObject);
                    #else
                    prefab = PrefabUtility.FindPrefabRoot(Selection.activeGameObject);
                    #endif
                }
                string smartSelection = "Scene";
                if (prefab && AssetDatabase.Contains(prefab))
                {
                    smartSelection = "Prefab";
                }
                else if (Selection.gameObjects.Length > 0)
                {
                    smartSelection = "Selection";
                }
                if (GUILayout.Button("Apply to " + smartSelection))
                {
                    AssignColorGroup(SelectedCG);
                }
                GUILayout.EndHorizontal();
                GUILayout.Space(3f);
            }
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
        }
Пример #16
0
    public void RegisterUI(string uiPath, EUIType eType, bool useBack, EUICanvas canvas, bool isAutoReset, bool preLoad = false, object tempObj = null)
    {
        string luaFileName = System.IO.Path.GetFileName(uiPath);

        if (m_uiDic.ContainsKey(luaFileName))
        {
            return;
        }

        GameObject obj = null;

        if (tempObj != null)
        {
            obj = tempObj as GameObject;
        }
        else
        {
            obj = Res.ResourcesManager.Instance.SyncGetResource <GameObject>(uiPath, Res.ResourceType.UI);
        }
        string name = obj.name.Replace("(Clone)", string.Empty);

        obj.name = name;
        UIBase uiBase = null;

        switch (luaFileName)
        {
        case EUIName.RegistUI:
            uiBase = obj.AddComponent <RegistUI>();
            break;

        case EUIName.BattleUI:
            uiBase = obj.AddComponent <BattleUI>();
            break;

        case EUIName.WallpaperUI:
            uiBase = obj.AddComponent <WallpaperUI>();
            break;

        case EUIName.HomeUI:
            uiBase = obj.AddComponent <HomeUI>();
            break;

        case EUIName.AccountUI:
            uiBase = obj.AddComponent <AccountUI>();
            break;

        case EUIName.ResigsterSucceesUI:
            uiBase = obj.AddComponent <ResigsterSucceesUI>();
            break;

        case EUIName.BattleCardShowUI:
            uiBase = obj.AddComponent <BattleCardShowUI>();
            break;

        case EUIName.SearchEnemyUI:
            uiBase = obj.AddComponent <SearchEnemyUI>();
            break;

        default:
            uiBase = obj.AddComponent <UIBase>();
            break;
        }

        uiBase.eUIType       = eType;
        uiBase.eUICanvas     = canvas;
        uiBase.useBack       = useBack;
        m_uiDic[luaFileName] = uiBase;
        RegisterUI(uiBase, canvas, isAutoReset);
    }
Пример #17
0
    public void OpenUI(string luaPath)
    {
        UIBase ui = null;

        if (m_uiDic.TryGetValue(luaPath, out ui))
        {
            EUIType eType = ui.eUIType + 9;
            if (ui.eUIType != EUIType.EUIType_None)
            {
                foreach (var item in m_uiDic.Values)
                {
                    if (item.eUIType > EUIType.EUIType_None)
                    {
                        if (item.eUIType != eType)///不是base UI
                        {
                            if (item.eUIType != ui.eUIType || (item.useBack == false && ui.useBack == false && item.eUIType != EUIType.EUIType_LoginBase))
                            {
                                item.CloseUI();
                                if (item.useBack == false)///关闭了其他类型的不带黑底的UI
                                {
                                    EUIType itemBase = item.eUIType + 9;
                                    if (itemBase != eType && _haveFullUI.ContainsKey(item.eUIType) && _haveFullUI[item.eUIType])
                                    {
                                        _haveFullUI[item.eUIType] = false;
                                    }
                                }
                            }
                        }
                        else///是base UI
                        {
                            if (ui.useBack == false)///没用黑底的就关闭base UI
                            {
                                item.CloseUI();
                            }
                        }
                    }
                }
            }

            if (ui.eUIType != EUIType.EUIType_None && ui.eUIType < EUIType.EUIType_FightBase)
            {
                foreach (var item in m_uiDic.Values)
                {
                    if (item.eUIType > EUIType.EUIType_None)
                    {
                        if (!item.activeSelf && item.eUIType == eType && ui.useBack)
                        {
                            if (_haveFullUI.ContainsKey(ui.eUIType) == false || _haveFullUI[ui.eUIType] == false)
                            {
                                item.OpenUI();
                                break;
                            }
                        }
                    }
                }
            }

            if (ui.useBack == false && ui.eUIType < EUIType.EUIType_NoneBase)
            {
                _haveFullUI[ui.eUIType] = true;
            }

            int DepthUtilsStart = DepthUtils.UI + 2;
            foreach (var item in m_uiDic.Values)
            {
                if (item != ui && item.useBack && ui.eUICanvas == EUICanvas.EUICanvas_Normal)
                {
                    item.SetOrderLayer(DepthUtilsStart);
                    DepthUtilsStart += 2;
                }
            }

            if (ui.useBack)
            {
                if (ui.eUICanvas == EUICanvas.EUICanvas_Normal)
                {
                    ui.SetOrderLayer(DepthUtilsStart);
                }
                else
                {
                    ui.Top();
                }
            }
            ui.OpenUI();

            Utility.Event.EventDispatcher.Dispatch(Utility.Event.EventType.UIEnumEvent, (int)eType);
        }
    }
Пример #18
0
        /// <summary>
        /// 对界面进行压栈
        /// </summary>
        /// <typeparam name="T">界面的类型</typeparam>
        /// <param name="uiType">界面对应的uiType</param>
        /// <param name="param">界面对应的压栈参数</param>
        public void ReplaceState <T>(EUIType uiType, object param = null) where T : BaseState
        {
            GameObject go = UIManager.GetInstance().GetSingleUI(uiType);

            ReplaceState <T>(go, param);
        }
Пример #19
0
        private void UpdateColors(ColorGroup cg)
        {
            Dictionary <string, NamedColor> old = new Dictionary <string, NamedColor>();

            for (int i = 0; i < cg.Count; i++)
            {
                NamedColor nc = cg[i];
                if (old.ContainsKey(nc.Name))
                {
                    continue;
                }
                old.Add(nc.Name, nc);
            }
            EUIType type = cg.uiMask;

            // Private checker for adding new keys to color List
            Action <string> CheckColor = (k) =>
            {
                if (old.ContainsKey(k))
                {
                    if (!cg.Contains(old[k]))
                    {
                        cg.Add(old[k]);
                    }
                }
                else
                {
                    cg.Add(new NamedColor(k, Color.white));
                }
            };

            Action <string> RemoveColor = (k) =>
            {
                if (old.ContainsKey(k) && cg.Contains(old[k]))
                {
                    cg.Remove(old[k]);
                }
            };

            if (((EUIType.Text | EUIType.RawImage | EUIType.Image) & type) == 0)
            {
                RemoveColor(UIVars.Color);
            }
            else
            {
                CheckColor(UIVars.Color);
            }

            if (((EUIType.Selectable | EUIType.Button | EUIType.Toggle) & type) == 0)
            {
                RemoveColor(UIVars.Normal);
                RemoveColor(UIVars.Highlighted);
                RemoveColor(UIVars.Pressed);
                RemoveColor(UIVars.Disabled);
            }
            else
            {
                CheckColor(UIVars.Normal);
                CheckColor(UIVars.Highlighted);
                CheckColor(UIVars.Pressed);
                CheckColor(UIVars.Disabled);
            }
        }
Пример #20
0
 public IUserInterface(string prefabName, EUIType type)
 {
     m_PrefabName = prefabName;
     m_Type       = type;
 }