コード例 #1
0
    /// <summary>
    /// 加载面板
    /// </summary>
    /// <typeparam name="T"></typeparam>
    private void LoadPanel <T>() where T : UIPanelBase
    {
        UIPanelID   id    = (UIPanelID)System.Enum.Parse(typeof(UIPanelID), typeof(T).ToString());
        UIPanelBase panel = System.Activator.CreateInstance(typeof(T)) as UIPanelBase;

        panelDict.Add(id, panel);
        //加载皮肤
        string     skinPath = panel.skinPath;
        GameObject skin     = ResourcesManager.Instance.LoadPrefab(skinPath);

        if (skin == null)
        {
            Debug.LogError("找不到路径" + skinPath + "的面板");
        }
        panel.skin = GameObject.Instantiate(skin);
        //设置父物体
        panel.skin.transform.SetParent(layerDict[panel.layer], false);
        //初始化,获取控件
        panel.OnLoad();
    }