【Debug】添加try...catch和日志测试
parent
4cf5adbb3f
commit
b60a4953ed
|
@ -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
|
||||||
|
|
|
@ -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:
|
||||||
|
|
|
@ -184,26 +184,33 @@ namespace Framework.Manager
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitNodesInfo()
|
private void InitNodesInfo()
|
||||||
{
|
{
|
||||||
foreach (var node in _curBuildData.NodeInfos)
|
try
|
||||||
{
|
{
|
||||||
var nodeInfo = new NodeInfo
|
foreach (var node in _curBuildData.NodeInfos)
|
||||||
{
|
{
|
||||||
Name = node.Name,
|
var nodeInfo = new NodeInfo
|
||||||
Options = new Dictionary<string, OptionInfo>(),
|
|
||||||
IconPath = node.IconPath
|
|
||||||
};
|
|
||||||
|
|
||||||
foreach (var option in node.Options)
|
|
||||||
{
|
|
||||||
var optionInfo = new OptionInfo()
|
|
||||||
{
|
{
|
||||||
Name = option
|
Name = node.Name,
|
||||||
|
Options = new Dictionary<string, OptionInfo>(),
|
||||||
|
IconPath = node.IconPath
|
||||||
};
|
};
|
||||||
|
|
||||||
nodeInfo.Options.Add(option, optionInfo);
|
foreach (var option in node.Options)
|
||||||
}
|
{
|
||||||
|
var optionInfo = new OptionInfo()
|
||||||
|
{
|
||||||
|
Name = option
|
||||||
|
};
|
||||||
|
|
||||||
NodeInfos.Add(nodeInfo.Name, nodeInfo);
|
nodeInfo.Options.Add(option, optionInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
NodeInfos.Add(nodeInfo.Name, nodeInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
DebugUtil.LogError("BuildManager.InitNodesInfo 初始化节点错误 :{0}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,63 +219,48 @@ namespace Framework.Manager
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitUserBuildInfo(UserBuildInfo userBuildInfo)
|
private void InitUserBuildInfo(UserBuildInfo userBuildInfo)
|
||||||
{
|
{
|
||||||
//游戏中传入数据
|
try
|
||||||
if (userBuildInfo != null)
|
|
||||||
{
|
{
|
||||||
_userBuildInfo = userBuildInfo;
|
//游戏中传入数据
|
||||||
}
|
if (userBuildInfo != null)
|
||||||
else
|
|
||||||
{
|
|
||||||
StorageManager.Instance.Init();
|
|
||||||
_userBuildInfo = StorageManager.Instance.GetStorage<UserBuildInfo>(GlobalConstants.UserBuildSaveKey);
|
|
||||||
if (_userBuildInfo == null)
|
|
||||||
{
|
{
|
||||||
var buildId = _curBuildData.buildID;
|
_userBuildInfo = userBuildInfo;
|
||||||
_userBuildInfo = new UserBuildInfo(buildId);
|
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
|
|
||||||
foreach (var nodeInfo in NodeInfos)
|
|
||||||
{
|
|
||||||
if (_userBuildInfo.ChooseNodeInfo.TryGetValue(nodeInfo.Key, out var option))
|
|
||||||
{
|
{
|
||||||
continue;
|
StorageManager.Instance.Init();
|
||||||
|
_userBuildInfo =
|
||||||
|
StorageManager.Instance.GetStorage<UserBuildInfo>(GlobalConstants.UserBuildSaveKey);
|
||||||
|
if (_userBuildInfo == null)
|
||||||
|
{
|
||||||
|
var buildId = _curBuildData.buildID;
|
||||||
|
_userBuildInfo = new UserBuildInfo(buildId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var optionInfo = nodeInfo.Value.GetOptionInfo();
|
foreach (var nodeInfo in NodeInfos)
|
||||||
if (optionInfo == null) return;
|
|
||||||
|
|
||||||
_userBuildInfo.ChooseNodeInfo.TryAdd(nodeInfo.Key, optionInfo.Name);
|
|
||||||
}
|
|
||||||
|
|
||||||
//打印Debug玩家Build信息
|
|
||||||
/*foreach (var infos in _userBuildInfo.ChooseNodeInfo)
|
|
||||||
{
|
|
||||||
DebugUtil.LogError("节点 {0} 选择的的是 {1}", infos.Key, infos.Value);
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 异步加载该建造物品图标
|
|
||||||
/// </summary>
|
|
||||||
private async UniTask InitIcon()
|
|
||||||
{
|
|
||||||
foreach (var nodeInfo in NodeInfos.Values)
|
|
||||||
{
|
|
||||||
foreach (var optionInfo in nodeInfo.Options.Values)
|
|
||||||
{
|
{
|
||||||
var index = GameBuildUtils.ExtractNumber(optionInfo.Name);
|
if (_userBuildInfo.ChooseNodeInfo.TryGetValue(nodeInfo.Key, out var option))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
optionInfo.IconName = await InitOptionIcon(nodeInfo.IconPath, index);
|
var optionInfo = nodeInfo.Value.GetOptionInfo();
|
||||||
|
if (optionInfo == null) return;
|
||||||
|
|
||||||
|
_userBuildInfo.ChooseNodeInfo.TryAdd(nodeInfo.Key, optionInfo.Name);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async void InitBlueprint()
|
//打印Debug玩家Build信息
|
||||||
{
|
/*foreach (var infos in _userBuildInfo.ChooseNodeInfo)
|
||||||
var path = string.Format(Constants.Constants.BuildBlueprint, _curBuildData.buildID);
|
{
|
||||||
DebugUtil.LogError("加载蓝图的路径:{0}", path);
|
DebugUtil.LogError("节点 {0} 选择的的是 {1}", infos.Key, infos.Value);
|
||||||
CurBlueprint = await AssetManager.Instance.LoadAssetAsync<Sprite>(path);
|
}*/
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
DebugUtil.LogError("BuildManager.InitUserBuildInfo 初始玩家信息错误 :{0}", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -276,41 +268,71 @@ namespace Framework.Manager
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitCondition()
|
private void InitCondition()
|
||||||
{
|
{
|
||||||
switch (_curBuildData.unlockType)
|
try
|
||||||
{
|
{
|
||||||
case UnlockType.ForGroup:
|
switch (_curBuildData.unlockType)
|
||||||
{
|
{
|
||||||
foreach (var unlockInfo in _curBuildData.unlockInfos)
|
case UnlockType.ForGroup:
|
||||||
{
|
{
|
||||||
var nodeName = string.Format(NodeName, unlockInfo.conditionGroup);
|
foreach (var unlockInfo in _curBuildData.unlockInfos)
|
||||||
if (NodeInfos.TryGetValue(nodeName, out var nodeInfo))
|
|
||||||
{
|
{
|
||||||
nodeInfo.Condition = unlockInfo.condition;
|
var nodeName = string.Format(NodeName, unlockInfo.conditionGroup);
|
||||||
//DebugUtil.LogError("挂点解锁:节点{0}的解锁条件是:{1}", nodeInfo.Name, unlockInfo.condition);
|
if (NodeInfos.TryGetValue(nodeName, out var nodeInfo))
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case UnlockType.ForThematic:
|
|
||||||
{
|
|
||||||
foreach (var unlockInfo in _curBuildData.unlockInfos)
|
|
||||||
{
|
|
||||||
var optionName = string.Format(OptionName, unlockInfo.conditionGroup);
|
|
||||||
foreach (var nodeInfo in NodeInfos.Values)
|
|
||||||
{
|
|
||||||
if (nodeInfo.Options.TryGetValue(optionName, out var optionInfo))
|
|
||||||
{
|
{
|
||||||
optionInfo.Condition = unlockInfo.condition;
|
nodeInfo.Condition = unlockInfo.condition;
|
||||||
DebugUtil.LogError("主题解锁:节点{0}的选项{1}的解锁条件是:{2}", nodeInfo.Name, optionInfo.Name,
|
//DebugUtil.LogError("挂点解锁:节点{0}的解锁条件是:{1}", nodeInfo.Name, unlockInfo.condition);
|
||||||
unlockInfo.condition);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
case UnlockType.ForThematic:
|
||||||
|
{
|
||||||
|
foreach (var unlockInfo in _curBuildData.unlockInfos)
|
||||||
|
{
|
||||||
|
var optionName = string.Format(OptionName, unlockInfo.conditionGroup);
|
||||||
|
foreach (var nodeInfo in NodeInfos.Values)
|
||||||
|
{
|
||||||
|
if (nodeInfo.Options.TryGetValue(optionName, out var optionInfo))
|
||||||
|
{
|
||||||
|
optionInfo.Condition = unlockInfo.condition;
|
||||||
|
DebugUtil.LogError("主题解锁:节点{0}的选项{1}的解锁条件是:{2}", nodeInfo.Name, optionInfo.Name,
|
||||||
|
unlockInfo.condition);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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>
|
||||||
|
@ -318,21 +340,45 @@ namespace Framework.Manager
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private async UniTask<string> InitOptionIcon(string iconsPath, int index)
|
private async UniTask<string> InitOptionIcon(string iconsPath, int index)
|
||||||
{
|
{
|
||||||
var fileEntries = Directory.GetFiles(iconsPath, "*.png");
|
try
|
||||||
foreach (var filePath in fileEntries)
|
|
||||||
{
|
{
|
||||||
var fileName = Path.GetFileName(filePath);
|
var fileEntries = Directory.GetFiles(iconsPath, "*.png");
|
||||||
var name = fileName.Replace(".png", "");
|
foreach (var filePath in fileEntries)
|
||||||
if (GameBuildUtils.ExtractNumber(name) == index)
|
|
||||||
{
|
{
|
||||||
var assetPath = filePath.Replace(Application.dataPath, "").Replace('\\', '/');
|
var fileName = Path.GetFileName(filePath);
|
||||||
var sprite = await AssetManager.Instance.LoadAssetAsync<Sprite>(assetPath);
|
var name = fileName.Replace(".png", "");
|
||||||
_iconSprites.TryAdd(name, sprite);
|
if (GameBuildUtils.ExtractNumber(name) == index)
|
||||||
return name;
|
{
|
||||||
|
var assetPath = filePath.Replace(Application.dataPath, "").Replace('\\', '/');
|
||||||
|
var sprite = await AssetManager.Instance.LoadAssetAsync<Sprite>(assetPath);
|
||||||
|
_iconSprites.TryAdd(name, sprite);
|
||||||
|
return name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
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>
|
||||||
|
|
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue