Exception堆栈追踪
上代码
try
{
SaveData saveData = SaveLoadManager.Load(migrate: false);
if (saveData != null)
{
Version v = new Version(saveData.gameVersion);
Version v2 = new Version(Cheats.version);
if (v < v2)
{
SaveLoadManager.MigrationBackupLocalSave();
SaveLoadManager.cloudSaveMustBeBackedUp = true;
}
saveData = SaveLoadManager.MigrateSaveData(saveData);
LoadSim(saveData, 0f, fromServer: false);
}
else
{
LoadSim(null, 0f, fromServer: false);
}
}
catch (Exception ex2)
{
if (string.IsNullOrEmpty(DEBUGerror))
{
DEBUGerror = "Error at Main.Start:" + System.Environment.NewLine;
DEBUGerror = DEBUGerror + ex2.Message + System.Environment.NewLine;
DEBUGerror += ex2.StackTrace;
}
UnityEngine.Debug.Log("!!!LOAD FAILED!!! Loading zero state");
UnityEngine.Debug.Log(ex2.Message);//具体错误信息
UnityEngine.Debug.Log(ex2.StackTrace);//显示错误的调用栈
ex = ex2;
SaveLoadManager.loadingSaveFailed = true;
}
UnityEngine.Debug.Log(ex2.Message);//具体错误信息
输出:Object reference not set to an instance of an object
UnityEngine.Debug.Log(ex2.StackTrace);//显示错误的调用栈
输出: at Simulation.Simulator.InitLoad (SaveLoad.SaveData saveData) [0x00327] in D:\SVN-MyHero\Assets\Scripts\Simulation\Simulator.cs:609
at Main.LoadSim (SaveLoad.SaveData saveData, System.Single additionalOfflineSimTime, System.Boolean fromServer, System.Boolean dontLoadAssets) [0x000e6] in D:\SVN-MyHero\Assets\Scripts\Main.cs:869
at Main.Start () [0x001a6] in D:\SVN-MyHero\Assets\Scripts\Main.cs:407