コード例 #1
0
    /// <summary>
    /// 跳转到目标界面
    /// </summary>
    /// <param name="uiRegisterName"></param>
    /// <param name="openArgs"></param>
    /// <param name="navArgs"></param>
    public static BaseUi Navigation2Ui(string uiRegisterName, List <string> openArgs, List <string> navArgs)
    {
        if (string.IsNullOrEmpty(uiRegisterName))
        {
            LoggerManager.Instance.Error("data error uiRegisterName is null");
            return(null);
        }

        Type t = Type.GetType(uiRegisterName, false, true);

#if UNITY_EDITOR
        if (t != null)
        {
            if (t.ToString() != uiRegisterName) // 防止大小写问题
            {
                LoggerManager.Instance.Info("try to get type for NavigationToUI, type : {0}", uiRegisterName);
                AssertHelper.Check(false, "can't get type of " + uiRegisterName);
                return(null);
            }
        }
        else
        {
            AssertHelper.AssertFalse(false, "数据配置错误", "跳转界面名=" + uiRegisterName + "不存在");
        }
#endif
        BaseUi ui = UiRelations.Instance.GetUi(t);
        if (ui == null || (!ui.IsShowing))
        {
            // 多人副本需要做更多的判断
            if (uiRegisterName.Equals(UiPrefabNames.UiPnlTeamDungeon))
            {
                if (DataModelManager.Instance.TeamDungeonInfo.IsInTeam)
                {
                    UiManager.Instance.ShowByName(UiPrefabNames.UiPnlTeamDungeonTeam);
                }
                else
                {
                    UiManager.Instance.ShowByName(UiPrefabNames.UiPnlTeamDungeon);
                }
            }
            else
            {
                ui = UiManager.Instance.ShowByName(uiRegisterName, openArgs.ToArray());
            }
        }

        if (ui != null && ui.IsShowing && navArgs != null && navArgs.Count > 0)
        {
            ui.MenuNavigation(navArgs);
        }

        return(ui);
    }