Exemple #1
0
    public void SetActive(eUIType uiType, bool state)
    {
        foreach (var uiItem in _cachedUI)
        {
            uiItem.Value.SetActive(false);
            //Destroy(((BaseViewController)uiItem.Value).gameObject);
        }

        if (!_cachedUI.ContainsKey(uiType))
        {
            var prefabToInstantiate = _uiPrefabs.FirstOrDefault(i => i.UiType.Equals(uiType));

            if (prefabToInstantiate == null)
            {
                throw new MissingReferenceException(String.Format("Couldn't find ui prefabe of type [{0}]", uiType));
            }

            var instantiatedGameObject = Instantiate(prefabToInstantiate.UiPrefab);
            _cachedUI.Add(uiType, ((IViewController)instantiatedGameObject.GetComponent <BaseViewController>()));
            _cachedUI[uiType].Initialize(_uiCanvas);
        }
        else
        {
            _cachedUI[uiType].SetActive(state);
        }
    }
Exemple #2
0
    // UI 생성 및 가져오기
    private GameObject GetUI(eUIType _uiType)
    {
        // Dictionary에 있으면 바로 리턴
        if (DicUI.ContainsKey(_uiType) == true)
        {
            return(DicUI[_uiType]);
        }
        GameObject makeUI   = null;
        GameObject prefabUI = Resources.Load("Prefabs/" + _uiType.ToString()) as GameObject;

        if (prefabUI != null)
        {
            if (ui == null)
            {
                ui = this.transform;
            }

            makeUI      = Instantiate(prefabUI, ui);
            makeUI.name = _uiType.ToString();

            DicUI.Add(_uiType, makeUI);
            makeUI.SetActive(false);    // 꺼서 반환
        }
        return(makeUI);
    }
Exemple #3
0
    public GameObject LoadAndPlace(string resourcePath, eUIType type, UIAnchor.Side?side, bool forced = false)
    {
        if (!forced && UIStack.Instance.IsLoadingScreenUp || !forced && UIStack.Instance.IsWaittingScreenUp)
        {
            return(null);
        }

        return(LoadAndPlace(resourcePath, ResolvePosition(type, side)));
    }
Exemple #4
0
    public void HideUI(eUIType _uiType, bool isSub = false)
    {
        GameObject showObject = GetUI(_uiType, isSub);

        if (showObject != null && showObject.activeSelf)
        {
            showObject.SetActive(false);
        }
    }
Exemple #5
0
    // UI 숨기기
    public void HideUI(eUIType _uiType)
    {
        GameObject showObject = GetUI(_uiType);

        if (showObject != null && showObject.activeSelf == true)
        {
            showObject.SetActive(false);
        }
    }
Exemple #6
0
        public void OpenOrRefreshUI <T>(eUIType type = eUIType.StackUI) where T : UIBase, new()
        {
            T ui = _getUIUnderRoot <T>();

            if (ui == null)
            {
                openUIInRoot <T>(type);
                return;
            }
            refreshUI <T>();
        }
Exemple #7
0
    public GameObject ShowUI(eUIType _uiType, bool isSub = false)
    {
        GameObject showObject = GetUI(_uiType, isSub);

        if (showObject != null && showObject.activeSelf == false)
        {
            showObject.SetActive(true);
        }

        return(showObject);
    }
Exemple #8
0
    /// <summary>
    /// UI 여는 함수
    /// </summary>
    /// <param name="eType"></param>
    public T OpenUI <T>(eUIType eType) where T : UIBase
    {
        UIData uiData = m_UIDic[eType];

        uiData.objUI.SetActive(true);
        UIBase uicomponent = (T)(uiData.objUI.GetComponent <UIBase>());

        uicomponent.Initialize();

        return((T)uicomponent);
    }
Exemple #9
0
    private int GetLobbyPanelPathIndex(eUIType type)
    {
        for (int i = 0; i < lobbyPanelPathArray.Length; i++)
        {
            if (lobbyPanelPathArray[i].type.Equals(type))
            {
                return(i);
            }
        }

        return(0);
    }
Exemple #10
0
    // UI 보이기
    public GameObject ShowUI(eUIType _uiType)
    {
        GameObject showObject = GetUI(_uiType);

        if (showObject != null && showObject.activeSelf == false)
        {
            showObject.SetActive(true);
        }
        else if (showObject == null)
        {
            Debug.LogError(_uiType + " is null");
        }
        return(showObject);
    }
Exemple #11
0
        /// <summary>
        /// 删除根节点下除指定类型的所有的UI
        /// </summary>
        public void removeUIUnderRootExceptType(eUIType type)
        {
            List <KeyValuePair <string, UIBase> > temp = new List <KeyValuePair <string, UIBase> >(_mdicUIUnderRoot);

            _StackUIList.Clear();

            for (int i = 0; i < temp.Count; i++)
            {
                UIBase uiobj = temp[i].Value;
                if (uiobj.mUIType != type)
                {
                    removeUI(uiobj);
                }
            }
        }
Exemple #12
0
    GameObject GetUI(eUIType _uiType, bool isDontDestroy)
    {
        if (isDontDestroy == false)
        {
            if (DicUI.ContainsKey(_uiType) == true)
            {
                return(DicUI[_uiType]);
            }
        }
        else
        {
            if (DicSubUI.ContainsKey(_uiType) == true)
            {
                return(DicSubUI[_uiType]);
            }
        }

        GameObject makeUI   = null;
        GameObject prefabUI =
            Resources.Load("Prefabs/UI/" + _uiType.ToString()) as GameObject;

        if (prefabUI != null)
        {
            if (isDontDestroy == false)
            {
                makeUI = NGUITools.AddChild(UI_CAMERA.gameObject, prefabUI);
                DicUI.Add(_uiType, makeUI);
            }
            else
            {
                if (SubRoot == null)
                {
                    GameObject root = Resources.Load("Prefabs/UI/SubUI_Root") as GameObject;

                    SubRoot       = NGUITools.AddChild(this.gameObject, root);
                    SubRoot.layer = LayerMask.NameToLayer("UI");
                }
                makeUI = NGUITools.AddChild(SubRoot, prefabUI);
                DicSubUI.Add(_uiType, makeUI);
            }

            makeUI.SetActive(false);
        }
        return(makeUI);
    }
Exemple #13
0
        /// <summary>
        /// 计算当前层级
        /// </summary>
        public int GetCanvasOder(eUIType rType)
        {
            //计算当前该UI的层级
            int curUIOrder = (int)rType;

            switch (rType)
            {
            case eUIType.SuperpositionUI:

                int[] canvasSuperArr = new int[_SuperpositionUIList.Count];

                for (int i = 0; i < _SuperpositionUIList.Count; i++)
                {
                    canvasSuperArr[i] = _SuperpositionUIList[i]._miUIOder;
                }

                if (canvasSuperArr.Length > 0)
                {
                    curUIOrder = Mathf.Max(canvasSuperArr) + 100;
                }
                break;

            case eUIType.StackUI:

                int[] canvasStackArr = new int[_StackUIList.Count];

                for (int i = 0; i < _StackUIList.Count; i++)
                {
                    if (_mdicUIUnderRoot.ContainsKey(_StackUIList[i]))
                    {
                        canvasStackArr[i] = _mdicUIUnderRoot[_StackUIList[i]]._miUIOder;
                    }
                }

                if (canvasStackArr.Length > 0)
                {
                    curUIOrder = Mathf.Max(canvasStackArr) + 100;
                }
                break;
            }

            return(curUIOrder);
        }
Exemple #14
0
    public UiInformation(eANCHOR anchor, string name, eUIType type, float left, float top, float right, float bottom)
    {
        Anchor = anchor;
        Name   = name;
        UIType = type;

        _left   = left;
        _top    = top;
        _right  = right;
        _bottom = bottom;

        // calculate width and height
        Width  = right - left;
        Height = bottom - top;

        // calcualte min and max anchor
        SetAnchor();

        // set delta position from anchor
        SetDeltaPosFromAnchor();
    }
Exemple #15
0
    private Transform ResolvePosition(eUIType uiType, UIAnchor.Side?side)
    {
        Transform result = null;

        switch (uiType)
        {
        case eUIType.HUD_Static:
            result = side.HasValue ? _staticHudAnchorMap[(int)side.Value] : _staticHudNoAnchor;
            break;

        case eUIType.NewPanel:
            AutoClosingContainer container = NGUITools.AddChild <AutoClosingContainer>(hudDynamicContainer.transform.parent.gameObject);
            if (side == null)
            {
                result = container.transform;
            }
            else
            {
                UIAnchor tempAnchor = NGUITools.AddChild <UIAnchor>(container.gameObject);
                tempAnchor.side = side.Value;
                tempAnchor.gameObject.AddComponent <AutoClosingContainer>();
                tempAnchor.uiCamera = UICamera.mainCamera;
                result = tempAnchor.transform;
            }
            break;

        case eUIType.None:
            if (hudDynamicContainer != null && hudDynamicContainer.transform != null)     // Max_G: fix a crash on exit in combat
            {
                result = hudDynamicContainer.transform.parent;
            }
            break;

        case eUIType.HUD_Dynamic:
            result = side.HasValue ? _dynamicHudAnchorMap[(int)side.Value] : _dynamicHudNoAnchor;
            break;
        }
        return(result);
    }
Exemple #16
0
 public string GetUIPath(eUIType type)
 {
     return(UIPath[(int)type]);
 }
Exemple #17
0
 public T GetUI <T>(eUIType type)
 {
     return((T)System.Convert.ChangeType(m_widgetRepositories.FindWidget(UIPath[(int)type]), typeof(T)));
 }
Exemple #18
0
    /// <summary>
    /// UI 여는 함수
    /// </summary>
    /// <param name="eType"></param>
    public void OpenUI(eUIType eType)
    {
        UIData uiData = m_UIDic[eType];

        uiData.objUI.SetActive(true);
    }
Exemple #19
0
 public IEnumerator OnCreateWidgetAsync <T>(eUIType type, System.Action <T> action, bool dontDestroyOnLoad = false)
     where T : UIBase
 {
     yield return(m_widgetRepositories.OnCreateWidgetAsync <T>(UIPath[(int)type], action, dontDestroyOnLoad));
 }
Exemple #20
0
    /// <summary>
    /// UI닫는 함수
    /// </summary>
    /// <param name="eType"></param>
    public void CloseUI(eUIType eType)
    {
        UIData uiData = m_UIDic[eType];

        uiData.objUI.SetActive(false);
    }
Exemple #21
0
 public T GetUI <T>(eUIType eType) where T : UIBase
 {
     return((T)(m_UIDic[eType].objUI.GetComponent <UIBase>()));
 }
Exemple #22
0
 public void Place(GameObject instance, eUIType type, UIAnchor.Side side)
 {
     Place(instance, ResolvePosition(type, side));
 }
Exemple #23
0
 public void openUIInRoot <T>(string perfabName, eUIType rUIType = eUIType.None, bool isSwitchDes = true) where T : UIBase, new()
 {
     openUIInRoot(typeof(T).Name, rUIType, isSwitchDes, perfabName);
 }
Exemple #24
0
        public void openUIInRoot(string className, eUIType rUIType = eUIType.None, bool isSwitchDes = true, string perfabName = "")
        {
            if (string.IsNullOrEmpty(perfabName))
            {
                perfabName = className;
            }

            UIBase ui = null;

            _mdicUIUnderRoot.TryGetValue(perfabName, out ui);

            if (ui == null)
            {
                addUIToRoot(perfabName, className);
                _mdicUIUnderRoot.TryGetValue(perfabName, out ui);;
            }
            else
            {
                switch (ui.mUIType)
                {
                case eUIType.SuperpositionUI:
                    ui.recoverOder();
                    // _SuperpositionUIList.Remove(ui);
                    break;

                case eUIType.StackUI:
                    //  _StackUIList.Remove(ui.uiTypeName);
                    ui.recoverOder();
                    break;

                case eUIType.TopUI:
                case eUIType.BaseUI:
                    ui.recoverOder();
                    break;

                default:
                    ui.recoverOder();
                    break;
                }

                ui.mUIType = rUIType;
            }



            if (ui != null)
            {
                if (_StackUIList.Contains(ui.uiTypeName))
                {
                    _StackUIList.Remove(ui.uiTypeName);
                }

                if (_SuperpositionUIList.Contains(ui))
                {
                    _SuperpositionUIList.Remove(ui);
                }


                if (rUIType != eUIType.None)
                {
                    ui.mUIType = rUIType;
                }

                ui.isSwichSceneDestroy = isSwitchDes;


                //设置UI层级
                ui.freshCanvasOder();

                switch (ui.mUIType)
                {
                case eUIType.SuperpositionUI:    //叠加UI
                    if (!_SuperpositionUIList.Contains(ui))
                    {
                        _SuperpositionUIList.Add(ui);
                    }
                    break;

                case eUIType.StackUI:    //堆栈UI
                    _StackUIList.Remove(ui.uiTypeName);
                    if (_StackUIList.Count > 0)
                    {
                        UIBase lastUI;
                        _mdicUIUnderRoot.TryGetValue(_StackUIList[_StackUIList.Count - 1], out lastUI);
                        if (lastUI != null)
                        {
                            DesUI(lastUI);
                        }
                    }
                    _StackUIList.Add(ui.uiTypeName);
                    break;
                }


                if (!_OpenUiList.Contains(ui))
                {
                    _OpenUiList.Add(ui);
                }

                SetUIActive(ui, true);


                if (ui.refreshFuncCallBack)
                {
                    ui.refreshFuncData     = null;
                    ui.refreshFuncCallBack = false;
                }
            }
            else
            {
                Debug.LogError("openUI failed! ==" + perfabName + "== not found!");
            }
        }
Exemple #25
0
 public void LoadAndPlaceAsync(System.Action <GameObject> fn, string resourcePath, eUIType type, UIAnchor.Side?side, bool forced = false)
 {
     if (!forced && UIStack.Instance.IsLoadingScreenUp || !forced && UIStack.Instance.IsWaittingScreenUp)
     {
         fn?.Invoke(null);
     }
     else
     {
         _LoadAndPlaceAsync(resourcePath, ResolvePosition(type, side), fn);
     }
 }
Exemple #26
0
 public void InitScaler(eUIType type, Action scaleEndCallback = null)
 {
     _uiType           = type;
     _scaleEndCallback = scaleEndCallback;
 }