Beispiel #1
0
    public GameObject ShowPanel(EUIPanel eUIPanel)
    {
        if (curUIPanels.ContainsKey(eUIPanel))
        {
            GameObject panel = curUIPanels[eUIPanel];

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

            return(curUIPanels[eUIPanel]);
        }

        string panelName = string.Format("UIPanel/{0}", eUIPanel.ToString()); //枚举名与Resources下文件名 一致

        GameObject uiPanel = GameObject.Instantiate(Resources.Load <GameObject>(panelName));

        Canvas canvas = uiPanel.GetComponent <Canvas>();

        if (canvas == null)
        {
            uiPanel.transform.SetParent(transform, false);
        }

        curUIPanels.Add(eUIPanel, uiPanel);

        uiPanel.gameObject.SetActive(true);

        return(uiPanel);
    }
Beispiel #2
0
    public GameObject GetPanel(EUIPanel eUIPanel)
    {
        if (!curUIPanels.ContainsKey(eUIPanel))
        {
#if UNITY_EDITOR
            Debug.LogWarning(" GetPanel Error ! No " + eUIPanel);
#endif
            return(null);
        }

        return(curUIPanels[eUIPanel]);
    }
Beispiel #3
0
    public bool DisablePanel(EUIPanel eUIPanel)
    {
        if (!curUIPanels.ContainsKey(eUIPanel))
        {
#if UNITY_EDITOR
            Debug.LogWarning(" GetPanel Error ! No " + eUIPanel);
#endif
            return(false);
        }

        curUIPanels[eUIPanel].SetActive(false);
        return(true);
    }
Beispiel #4
0
    public void ClosePanel(EUIPanel eUIPanel)
    {
        if (!curUIPanels.ContainsKey(eUIPanel))
        {
#if UNITY_EDITOR
            Debug.LogWarning(" 该UI界面 不存在 ! No " + eUIPanel);
#endif
            return;
        }

        //TODO  可以考虑 延迟5秒销毁
        GameObject.Destroy(curUIPanels[eUIPanel]);
        curUIPanels.Remove(eUIPanel);
    }