diff --git a/src/Luban.Client/Luban.Client.csproj b/src/Luban.Client/Luban.Client.csproj
index 3927c30..b0180e1 100644
--- a/src/Luban.Client/Luban.Client.csproj
+++ b/src/Luban.Client/Luban.Client.csproj
@@ -22,6 +22,10 @@
+
+
+
+
diff --git a/src/Luban.Client/Properties/launchSettings.json b/src/Luban.Client/Properties/launchSettings.json
index e0aca35..b6c4ae4 100644
--- a/src/Luban.Client/Properties/launchSettings.json
+++ b/src/Luban.Client/Properties/launchSettings.json
@@ -2,8 +2,8 @@
"profiles": {
"Luban.Client": {
"commandName": "Project",
- "commandLineArgs": "-h %LUBAN_SERVER_IP% -j cfg -w ..\\DesignerConfigs\\Datas -- -d ..\\DesignerConfigs\\Defines\\__root__.xml --input_data_dir ..\\DesignerConfigs\\Datas --output_code_dir TsScripts/src/Gen/Cfg --output_data_dir ConfigData --gen_types code_typescript_bin,data_bin -s client --export_test_data --validate_root_dir Assets ",
- "workingDirectory": "C:\\workspace\\unity-world\\Client"
+ "commandLineArgs": "-h %LUBAN_SERVER_IP% -j cfg -- -d ..\\..\\DesignerConfigs\\Defines\\__root__.xml --input_data_dir ..\\..\\DesignerConfigs\\Datas --output_code_dir Assets/Gen --output_data_dir ..\\GenerateDatas\\json --gen_types code_cs_unity_json,data_json -s all --validate_root_dir .",
+ "workingDirectory": "D:\\workspace\\luban_examples\\Projects\\Csharp_Unity_json"
},
"Luban.Client-db": {
"commandName": "Project",
diff --git a/src/Luban.Client/Source/Net/GenClient.cs b/src/Luban.Client/Source/Net/GenClient.cs
index d765466..c49944a 100644
--- a/src/Luban.Client/Source/Net/GenClient.cs
+++ b/src/Luban.Client/Source/Net/GenClient.cs
@@ -8,11 +8,14 @@ using Luban.Client.Common.Utils;
using Luban.Common.Protos;
using Luban.Common.Utils;
using System;
+using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
+using System.Text.RegularExpressions;
using System.Threading.Tasks;
+using YamlDotNet.RepresentationModel;
namespace Luban.Client.Common.Net
{
@@ -163,14 +166,84 @@ namespace Luban.Client.Common.Net
Session.ReplyRpc(rpc, res);
}
+ private readonly Regex _subResPattern = new Regex(@"(.+)\[(\d+)]$");
+
+ private readonly ConcurrentDictionary _cacheYamlDocs = new();
+
+ private YamlDocument GetCacheYamlDoc(string mainResFileName)
+ {
+ return _cacheYamlDocs.GetOrAdd(mainResFileName, (file) =>
+ {
+ var yamlStream = new YamlStream();
+ yamlStream.Load(new StreamReader(new FileStream(mainResFileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)));
+ return yamlStream.Documents[0];
+ });
+ }
+
+ private bool CheckSubResourceExists(string mainResFileName, string subResName)
+ {
+ s_logger.Debug("check resources main:{} sub:{}", mainResFileName, subResName);
+ if (!File.Exists(mainResFileName))
+ {
+ return false;
+ }
+ try
+ {
+ var yamlNode = (YamlMappingNode) GetCacheYamlDoc(mainResFileName).RootNode;
+ var yamlSubResName = new YamlScalarNode(subResName);
+ foreach (var (resType, node) in yamlNode)
+ {
+
+ switch(resType.ToString())
+ {
+ case "SpriteAtlas":
+ {
+ var mnode = (YamlMappingNode)node;
+ var r = (YamlSequenceNode) mnode[new YamlScalarNode("m_PackedSpriteNamesToIndex")];
+ if (r == null)
+ {
+ return false;
+ }
+ return r.Contains(yamlSubResName);
+ }
+ }
+ }
+
+ return false;
+ }
+ catch (Exception ex)
+ {
+ s_logger.Error(ex);
+ return false;
+ }
+ }
+
private void Process(QueryFilesExists p)
{
var root = p.Arg.Root;
var files = p.Arg.Files;
var re = new QueryFilesExistsRes() { Exists = new List(files.Count) };
+
+ var tasks = new List>();
+
foreach (var f in files)
{
- re.Exists.Add(File.Exists(Path.Combine(root, f)));
+ var match = _subResPattern.Match(f);
+ if (match.Success)
+ {
+ var groups = match.Groups;
+ tasks.Add(Task.Run(() => CheckSubResourceExists(Path.Join(root, groups[1].Value), groups[2].Value)));
+ }
+ else
+ {
+ tasks.Add(Task.Run(() => File.Exists(Path.Combine(root, f))));
+ }
+ }
+
+ Task.WhenAll(tasks);
+ foreach (var task in tasks)
+ {
+ re.Exists.Add(task.Result);
}
Session.ReplyRpc(p, re);
}