【建造】修改图标加载路径

iOS_release
zhangaotian 2024-07-19 17:18:17 +08:00
parent 5a8545c5b2
commit 13d8c42778
80 changed files with 16 additions and 36 deletions

View File

Before

Width:  |  Height:  |  Size: 8.8 KiB

After

Width:  |  Height:  |  Size: 8.8 KiB

View File

Before

Width:  |  Height:  |  Size: 9.0 KiB

After

Width:  |  Height:  |  Size: 9.0 KiB

View File

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 7.6 KiB

View File

Before

Width:  |  Height:  |  Size: 8.2 KiB

After

Width:  |  Height:  |  Size: 8.2 KiB

View File

@ -34,7 +34,7 @@
"Option2",
"Option3"
],
"IconPath": "Assets/Art/GameBuild/Texture/Series_Spring/Node1/Icon"
"IconPath": "Assets/Art/GameBuild/Texture/Build_1/Node1/Icon/{0}.png"
},
{
"name": "Node2",
@ -43,7 +43,7 @@
"Option2",
"Option3"
],
"IconPath": "Assets/Art/GameBuild/Texture/Series_Spring/Node2/Icon"
"IconPath": "Assets/Art/GameBuild/Texture/Build_1/Node2/Icon/{0}.png"
},
{
"name": "Node3",
@ -52,7 +52,7 @@
"Option2",
"Option3"
],
"IconPath": "Assets/Art/GameBuild/Texture/Series_Spring/Node3/Icon"
"IconPath": "Assets/Art/GameBuild/Texture/Build_1/Node3/Icon/{0}.png"
},
{
"name": "Node4",
@ -61,7 +61,7 @@
"Option2",
"Option3"
],
"IconPath": "Assets/Art/GameBuild/Texture/Series_Spring/Node4/Icon"
"IconPath": "Assets/Art/GameBuild/Texture/Build_1/Node4/Icon/{0}.png"
},
{
"name": "Node5",
@ -70,7 +70,7 @@
"Option2",
"Option3"
],
"IconPath": "Assets/Art/GameBuild/Texture/Series_Spring/Node5/Icon"
"IconPath": "Assets/Art/GameBuild/Texture/Build_1/Node5/Icon/{0}.png"
}
]
}

View File

@ -99,7 +99,7 @@ public class GameBuildWindow : OdinEditorWindow
editorNode.BuildNode = node;
if (!string.IsNullOrEmpty(node.IconPath))
editorNode.optionPath = node.IconPath.Replace("Icon", "Normal");
editorNode.optionPath = node.IconPath.Replace("Icon/{0}.png", "Normal");
editorNodes.Add(editorNode);
}
}
@ -259,7 +259,7 @@ public class GameBuildWindow : OdinEditorWindow
sortingOrder++;
//初始化Icon资源路径
editorNode.BuildNode.IconPath = editorNode.optionPath.Replace("Normal", "Icon");
editorNode.BuildNode.IconPath = editorNode.optionPath.Replace("Normal", "Icon/{0}.png");
}
}

View File

@ -102,7 +102,7 @@ namespace Framework.Manager
{
public string Name;
public string IconName;
public string IconPath;
//按主题解锁条件
public int Condition;
@ -337,9 +337,7 @@ namespace Framework.Manager
{
foreach (var optionInfo in nodeInfo.Options.Values)
{
var index = GameBuildUtils.ExtractNumber(optionInfo.Name);
optionInfo.IconName = await InitOptionIcon(nodeInfo.IconPath, index);
optionInfo.IconPath = await InitOptionIcon(nodeInfo.IconPath, optionInfo.Name);
}
}
}
@ -352,26 +350,15 @@ namespace Framework.Manager
/// <summary>
/// 初始化加载选项图标
/// </summary>
private async UniTask<string> InitOptionIcon(string iconsPath, int index)
private async UniTask<string> InitOptionIcon(string iconsPath, string optionName)
{
try
{
var path = iconsPath.Replace(Application.dataPath, "").Replace('\\', '/');
DebugUtil.LogError("路径:{0}", path);
var fileEntries = Directory.GetFiles(path, "*.png");
foreach (var filePath in fileEntries)
{
var fileName = Path.GetFileName(filePath);
var name = fileName.Replace(".png", "");
if (GameBuildUtils.ExtractNumber(name) == index)
{
var assetPath = filePath.Replace(Application.dataPath, "").Replace('\\', '/');
var path = string.Format(iconsPath, optionName);
var assetPath = path.Replace(Application.dataPath, "").Replace('\\', '/');
var sprite = await AssetManager.Instance.LoadAssetAsync<Sprite>(assetPath);
_iconSprites.TryAdd(name, sprite);
return name;
}
}
if (_iconSprites.TryAdd(path, sprite))
return path;
return null;
}
catch (Exception e)
@ -406,7 +393,7 @@ namespace Framework.Manager
{
if (nodeInfo.Options.TryGetValue(optionName, out var optionInfo))
{
if (_iconSprites.TryGetValue(optionInfo.IconName, out var sprite))
if (_iconSprites.TryGetValue(optionInfo.IconPath, out var sprite))
return sprite;
}
}

View File

@ -63,13 +63,6 @@ namespace Gameplay.LoadingExecutor
var buildPath = string.Format(Framework.Constants.Constants.SceneBuildPath, buildId);
var buildConfig = string.Format(Framework.Constants.Constants.BuildConfigPath, buildId);
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 Addressables.LoadSceneAsync(buildPath).ToUniTask();
}