Example #1
0
    /// <summary>
    /// 界面入栈
    /// </summary>
    /// <param name="panelType"></param>
    public static void PushPanel <T>(params object[] para) where T : BasePanel
    {
        if (panelStack.Count > 0)
        {
            BasePanel bp1 = panelStack.Peek();
            bp1.OnPause();
        }

        string name = typeof(T).ToString();

        if (panels.ContainsKey(name))
        {
            return;
        }
        BasePanel panel = root.gameObject.AddComponent <T>();

        panel.OnInit();
        panel.Init();
        Transform layer = layers[panel.layer];

        panel.skin.transform.SetParent(layer, false);
        panels.Add(name, panel);
        panel.OnShow(para);

        panelStack.Push(panel);
        Debug.Log("stack count: " + panelStack.Count);
    }
    // 根据面板类型 得到实例化的面板
    private BasePanel GetPanel(UIPanelType panelType)
    {
        BasePanel panel = panelDict.TryGet(panelType);

        if (panel != null)
        {
            return(panel);
        }

        //如果找不到,那么就找这个面板的prefab的路径,然后去根据prefab去实例化面板
        string     path      = string.Format("UIPanel/{0}Panel", panelType);
        GameObject instPanel = Object.Instantiate(Resources.Load(path)) as GameObject;

        if (instPanel == null)
        {
            Debug.Log(string.Format("未能实例化指定[{0}]类型的Panel", panelType));
            return(null);
        }

        instPanel.transform.SetParent(canvasTransform, false);
        BasePanel basePanel = instPanel.GetComponent <BasePanel>();

        basePanel.Init(Facade, this);
        panelDict.Add(panelType, basePanel);
        return(basePanel);
    }
Example #3
0
 //加载面板
 private void LoadUIPanels()
 {
     foreach (KeyValuePair <UIPanelType, string> panelPath in _UIPanelPaths)
     {
         GameObject go = GameObject.Instantiate(Resources.Load(panelPath.Value)) as GameObject;
         go.transform.SetParent(_CanvasTransform, false);
         BasePanel panel = go.GetComponent <BasePanel>();
         panel.Init();
         _UIPanelObjects.Add(panelPath.Key, panel);
     }
 }
Example #4
0
 private static void AddPanel(BasePanel panel)
 {
     if (panel.NeedBlackForm)
     {
         BlackWallForm.Instance.Init(formWidth, formHeight);
         MainForm.Instance.AddPanelAct(BlackWallForm.Instance);
     }
     else
     {
         panelList.Add(panel);
     }
     panel.Init(formWidth, formHeight);
     MainForm.Instance.AddPanelAct(panel);
     PanelCount++;
 }
Example #5
0
    /// <summary>
    /// 创建一个panel.
    /// </summary>
    /// <returns>
    /// The panel.
    /// </returns>
    /// <param name='panelName'>
    /// Panel name.
    /// </param>
    public IEnumerator CreatePanel(string panelName)
    {
        BasePanel panel = null;

        if (panels.TryGetValue(panelName, out panel))
        {
            //			NGUITools.SetActive(panel.gameObject, true);
        }
        else
        {
            ResGameObject obj = new ResGameObject();
            yield return(StartCoroutine(ResManager.GetInstance().Load(Config.PanelPath + panelName, obj)));

            GameObject gameObj = NGUITools.AddChild(baseWindow, obj.obj as GameObject);
            panel = gameObj.GetComponent <BasePanel>();
            yield return(StartCoroutine(panel.Init()));

            panels.Add(panelName, panel);
        }
    }
Example #6
0
        public BasePanel GetPanel(string panelType)
        {
            if (_panelDict == null)
            {
                _panelDict = new Dictionary <string, BasePanel>();
            }
            BasePanel panel = _panelDict.GetValue(panelType);

            // 如果没有实例化面板,寻找路径进行实例化,并且存储到已经实例化好的字典面板中
            if (panel == null)
            {
                string path = _panelPathDict.GetValue(panelType);

                GameObject panelGo = Instantiate(Resources.Load <GameObject>(path), CanvasTransform, false);
                panel = panelGo.GetComponent <BasePanel>();
                _panelDict.Add(panelType, panel);
                panel.Init();
            }
            return(panel);
        }
Example #7
0
    public static void Open <T>(params object[] para) where T : BasePanel
    {
        string name = typeof(T).ToString();

        if (panels.ContainsKey(name))
        {
            return;
        }

        BasePanel panel = root.gameObject.AddComponent <T>();

        panel.OnInit();
        panel.Init();
        // 父容器
        Transform layer = layers[panel.layer];

        panel.skin.transform.SetParent(layer, false);
        panels.Add(name, panel);
        panel.OnShow(para);
    }
Example #8
0
    //打开面板
    public static void Open <T>(params object[] para) where T : BasePanel
    {
        string name = typeof(T).ToString();

        //已经打开
        if (panels.ContainsKey(name))
        {
            return;
        }
        //组件
        BasePanel panel = canvas.gameObject.AddComponent <T>();

        panel.OnInit();
        panel.Init();
        //父容器
        Transform layer = layers[panel.layer];

        panel.prefabIns.transform.SetParent(layer, false);
        //列表
        panels.Add(name, panel);
        //OnShow
        panel.OnShow();
        panel.OnShow(para);
    }