c# - 将 2018.1.f1 更新到 2019 后的 Unity3D 我得到了数千个异常
问题描述
我有一个2018年1.1f1版本写的统一游戏。我想在2019.1.0f2版本中打开它。
我将项目设置中的运行时脚本版本从 .net 2.0 更改为 .net 4.0 等效版本。之后,当我按下播放按钮时,unity 会给出数千个 nullReferenceExceptions 和 ArgumentOutOfRangeExceptions。
我删除了 library、obj 和 temp 文件夹,但没有用。
我认为统一没有看到脚本文件。我不知道该怎么做。
是因为不推荐使用的对象吗?
我该如何解决这个问题?
谢谢,
编辑:
@科林杨
- 附加到其游戏对象的所有脚本
- 已加载所有插件。又重新加载了。
- 尝试在视觉工作室中保存退出和重新打开和构建。
- 升级到 2019 后出现这些错误。我还将 Visual Studio 从 2017 升级到 2019。vs 2019 已经有统一游戏开发包。
- Visual Studio 不会抛出任何错误,只会提醒已弃用的类和方法。
@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为空。
解决方案
推荐阅读
- php - 检查数据库中数据的视图状态并停止链接闪烁
- pandas - 是否可以只从 pandas 导入 DataFrame 和读取 excel 的功能?
- python - 合并排序:如何以递减方式排序?
- sqlite - 需要在 Ionic 4 的 SQLite 中存储文件/pdf
- java - Selenium,如何复制几个总是不同的单词?
- javascript - 如何过滤多维数组对象
- ruby-on-rails - Rails 5:如何从 API 的响应中保存 Array of Hash 中的 uniq 元素
- kubernetes - 这里实际节点的 CPU 和内存容量是多少?
- css - 如何制作浮动:相对位置下降?
- python - 如何加快我的python字典循环?