首页 > 解决方案 > 将 2018.1.f1 更新到 2019 后的 Unity3D 我得到了数千个异常

问题描述

我有一个2018年1.1f1版本写的统一游戏。我想在2019.1.0f2版本中打开它。

我将项目设置中的运行时脚本版本从 .net 2.0 更改为 .net 4.0 等效版本。之后,当我按下播放按钮时,unity 会给出数千个 nullReferenceExceptions 和 ArgumentOutOfRangeExceptions。

我删除了 library、obj 和 temp 文件夹,但没有用。

我认为统一没有看到脚本文件。我不知道该怎么做。

是因为不推荐使用的对象吗?

我该如何解决这个问题?

谢谢,

在此处输入图像描述

编辑

@科林杨

@BugFinder,@LeafLayer 这是你提到的脚本文件。Update 方法中实际上发生了数以千计的错误。在您发表评论后,我意识到这一点。

public class LoginMenuLanguageSupporter : MonoBehaviour {

    public GameObject LogoutButton;
    public GameObject LoginButton;
    public GameObject UserNameHintInputField;
    public GameObject PasswordHintInputField;
    public GameObject RememberMe;
    public GameObject LoggingPanelText;
    public GameObject SloganText;
    public GameObject loadingText;

    private LocalizationSupport LocalizationSupport;
    private LanguageCode PrevLanguageCode;
    void Start()
    {
        //localization bilgileri 
        if (GameObject.Find(Settings.Localization))
            LocalizationSupport = GameObject.Find(Settings.Localization).GetComponent<LocalizationSupport>();

        PrevLanguageCode = LocalizationSupport.SelectedLanguage;
        SetLanguages();
    }

    void Update()
    {
        if (LocalizationSupport.SelectedLanguage.Code.Equals(PrevLanguageCode.Code))
            return;

        PrevLanguageCode = LocalizationSupport.SelectedLanguage;
        SetLanguages();
    }

    void SetLanguages()
    {
        SetLanguage(ref LogoutButton, "exit");
        SetLanguage(ref LoginButton, "login");
        SetLanguage(ref UserNameHintInputField, "username");
        SetLanguage(ref PasswordHintInputField, "password");
        SetLanguage(ref RememberMe, "rememberme");
        SetLanguage(ref LoggingPanelText, "loggingon");
        SetLanguage(ref SloganText, "slogan");
        SetLanguage(ref loadingText, "loggingon");
    }

    void SetLanguage(ref GameObject go, string code)
    {
        go.GetComponent<Text>().text = string.IsNullOrEmpty(LocalizationSupport.Translate(code)) ? go.GetComponent<Text>().text : LocalizationSupport.Translate(code);
    }

}

编辑2:

是的。PrevLanguageCode为空。

标签: c#unity3d

解决方案


推荐阅读