【混淆】防崩溃

main
刘涛 2025-10-28 13:09:08 +08:00
parent 80fabc8f94
commit 7fbd9ad15f
2 changed files with 15 additions and 2 deletions

View File

@ -4,8 +4,10 @@ using cfg.FightCfg;
using Sirenix.OdinInspector;
using UnityEngine;
using Newtonsoft.Json;
using Obfuz;
[Serializable]
[ObfuzIgnore]
public class MapData
{
[Serializable]

View File

@ -53,8 +53,19 @@ public static class MapUtils
DebugUtil.Log("[MapUtils: LoadMapData] ------------ 4");
MapData mapData = null;
DebugUtil.Log("[MapUtils: LoadMapData] ------------ 5");
if (textAsset is not null)
mapData = JsonUtility.FromJson<MapData>(textAsset.text);
try
{
// 这里可能会抛异常,捕获一下避免程序崩溃
if (textAsset is not null)
{
mapData = JsonUtility.FromJson<MapData>(textAsset.text);
}
}
catch (Exception e)
{
DebugUtil.LogError("LoadMap.LoadMap failed, exception:{0}", e.ToString());
}
DebugUtil.Log("[MapUtils: LoadMapData] ------------ 6");
if (null == mapData)
DebugUtil.LogError("LoadMap.LoadMap failed, can not find map config: {0}", mapPath);