【Debug】添加try...catch和日志测试

iOS_release
zhangaotian 2024-07-19 14:17:49 +08:00
parent 4cf5adbb3f
commit b60a4953ed
4 changed files with 156 additions and 98 deletions

View File

@ -15,7 +15,7 @@ MonoBehaviour:
m_DefaultGroup: d58d9f3a3b49b264e94d9dd1182e2910 m_DefaultGroup: d58d9f3a3b49b264e94d9dd1182e2910
m_currentHash: m_currentHash:
serializedVersion: 2 serializedVersion: 2
Hash: 055613adb1a6e9184deaa9c262f9202f Hash: 3980b428a3d1445ac52889f7249df15d
m_OptimizeCatalogSize: 0 m_OptimizeCatalogSize: 0
m_BuildRemoteCatalog: 0 m_BuildRemoteCatalog: 0
m_BundleLocalCatalog: 0 m_BundleLocalCatalog: 0

View File

@ -27,6 +27,11 @@ MonoBehaviour:
m_ReadOnly: 0 m_ReadOnly: 0
m_SerializedLabels: [] m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0 FlaggedDuringContentUpdateRestriction: 0
- m_GUID: b5b08b0ba867e46bd90a825d41b818c9
m_Address: Assets/Config/Build
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
m_ReadOnly: 0 m_ReadOnly: 0
m_Settings: {fileID: 11400000, guid: ed93b85c5b1133d4c93abe6c976cf739, type: 2} m_Settings: {fileID: 11400000, guid: ed93b85c5b1133d4c93abe6c976cf739, type: 2}
m_SchemaSet: m_SchemaSet:

View File

@ -183,6 +183,8 @@ namespace Framework.Manager
/// 初始化该Build场景的节点信息 /// 初始化该Build场景的节点信息
/// </summary> /// </summary>
private void InitNodesInfo() private void InitNodesInfo()
{
try
{ {
foreach (var node in _curBuildData.NodeInfos) foreach (var node in _curBuildData.NodeInfos)
{ {
@ -206,11 +208,18 @@ namespace Framework.Manager
NodeInfos.Add(nodeInfo.Name, nodeInfo); NodeInfos.Add(nodeInfo.Name, nodeInfo);
} }
} }
catch (Exception e)
{
DebugUtil.LogError("BuildManager.InitNodesInfo 初始化节点错误 :{0}", e);
}
}
/// <summary> /// <summary>
/// 初始化存盘信息 /// 初始化存盘信息
/// </summary> /// </summary>
private void InitUserBuildInfo(UserBuildInfo userBuildInfo) private void InitUserBuildInfo(UserBuildInfo userBuildInfo)
{
try
{ {
//游戏中传入数据 //游戏中传入数据
if (userBuildInfo != null) if (userBuildInfo != null)
@ -220,7 +229,8 @@ namespace Framework.Manager
else else
{ {
StorageManager.Instance.Init(); StorageManager.Instance.Init();
_userBuildInfo = StorageManager.Instance.GetStorage<UserBuildInfo>(GlobalConstants.UserBuildSaveKey); _userBuildInfo =
StorageManager.Instance.GetStorage<UserBuildInfo>(GlobalConstants.UserBuildSaveKey);
if (_userBuildInfo == null) if (_userBuildInfo == null)
{ {
var buildId = _curBuildData.buildID; var buildId = _curBuildData.buildID;
@ -247,34 +257,18 @@ namespace Framework.Manager
DebugUtil.LogError("节点 {0} 选择的的是 {1}", infos.Key, infos.Value); DebugUtil.LogError("节点 {0} 选择的的是 {1}", infos.Key, infos.Value);
}*/ }*/
} }
catch (Exception e)
/// <summary>
/// 异步加载该建造物品图标
/// </summary>
private async UniTask InitIcon()
{ {
foreach (var nodeInfo in NodeInfos.Values) DebugUtil.LogError("BuildManager.InitUserBuildInfo 初始玩家信息错误 :{0}", e);
{
foreach (var optionInfo in nodeInfo.Options.Values)
{
var index = GameBuildUtils.ExtractNumber(optionInfo.Name);
optionInfo.IconName = await InitOptionIcon(nodeInfo.IconPath, index);
} }
} }
}
private async void InitBlueprint()
{
var path = string.Format(Constants.Constants.BuildBlueprint, _curBuildData.buildID);
DebugUtil.LogError("加载蓝图的路径:{0}", path);
CurBlueprint = await AssetManager.Instance.LoadAssetAsync<Sprite>(path);
}
/// <summary> /// <summary>
/// 初始化条件 /// 初始化条件
/// </summary> /// </summary>
private void InitCondition() private void InitCondition()
{
try
{ {
switch (_curBuildData.unlockType) switch (_curBuildData.unlockType)
{ {
@ -312,11 +306,41 @@ namespace Framework.Manager
} }
} }
} }
catch (Exception e)
{
DebugUtil.LogError("BuildManager.InitCondition 初始化条件错误 :{0}", e);
}
}
/// <summary>
/// 异步加载该建造物品图标
/// </summary>
private async UniTask InitIcon()
{
try
{
foreach (var nodeInfo in NodeInfos.Values)
{
foreach (var optionInfo in nodeInfo.Options.Values)
{
var index = GameBuildUtils.ExtractNumber(optionInfo.Name);
optionInfo.IconName = await InitOptionIcon(nodeInfo.IconPath, index);
}
}
}
catch (Exception e)
{
DebugUtil.LogError("BuildManager.InitIcon 初始化图标数据错误 :{0}", e);
}
}
/// <summary> /// <summary>
/// 初始化加载选项图标 /// 初始化加载选项图标
/// </summary> /// </summary>
private async UniTask<string> InitOptionIcon(string iconsPath, int index) private async UniTask<string> InitOptionIcon(string iconsPath, int index)
{
try
{ {
var fileEntries = Directory.GetFiles(iconsPath, "*.png"); var fileEntries = Directory.GetFiles(iconsPath, "*.png");
foreach (var filePath in fileEntries) foreach (var filePath in fileEntries)
@ -334,6 +358,28 @@ namespace Framework.Manager
return null; return null;
} }
catch (Exception e)
{
DebugUtil.LogError("BuildManager.InitOptionIcon 加载选项图标错误, 路径: {0}, Error: {1}", iconsPath, e);
return null;
}
}
/// <summary>
/// 加载当前场景蓝图
/// </summary>
private async void InitBlueprint()
{
try
{
var path = string.Format(Constants.Constants.BuildBlueprint, _curBuildData.buildID);
CurBlueprint = await AssetManager.Instance.LoadAssetAsync<Sprite>(path);
}
catch (Exception e)
{
DebugUtil.LogError("BuildManager.InitBlueprint 加载蓝图错误 :{0}", e);
}
}
/// <summary> /// <summary>
/// 获得选项Icon图标 /// 获得选项Icon图标

View File

@ -63,6 +63,13 @@ namespace Gameplay.LoadingExecutor
var buildPath = string.Format(Framework.Constants.Constants.SceneBuildPath, buildId); var buildPath = string.Format(Framework.Constants.Constants.SceneBuildPath, buildId);
var buildConfig = string.Format(Framework.Constants.Constants.BuildConfigPath, buildId); var buildConfig = string.Format(Framework.Constants.Constants.BuildConfigPath, buildId);
var buildData = await JsonHelper.LoadFromAddressable<BuildData>(buildConfig); var buildData = await JsonHelper.LoadFromAddressable<BuildData>(buildConfig);
//Debug TODO 删除
DebugUtil.LogError("当前buildID: {0}", buildData.buildID);
foreach (var nodeInfo in buildData.NodeInfos)
{
DebugUtil.LogError("加载{0}图标路径:{1}", nodeInfo.Name, nodeInfo.IconPath);
}
await BuildManager.Instance.Init(buildData, true, buildInfo); await BuildManager.Instance.Init(buildData, true, buildInfo);
await Addressables.LoadSceneAsync(buildPath).ToUniTask(); await Addressables.LoadSceneAsync(buildPath).ToUniTask();
} }