From 8e08e3630dc2530362d11a8593c41a154415f3c6 Mon Sep 17 00:00:00 2001 From: ninemine <1371605831@qq.com> Date: Wed, 1 Oct 2025 20:51:48 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BF=AE=E6=94=B9=E4=BB=A5=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E5=8F=AF=E9=80=89Interaction=E6=94=AF=E6=8C=81\n2.=E5=B9=B6?= =?UTF-8?q?=E4=BF=AE=E5=A4=8DParse=E5=87=BD=E6=95=B0=E4=B8=AD=E6=AD=A3?= =?UTF-8?q?=E5=88=99=E8=A1=A8=E8=BE=BE=E5=BC=8F=E7=9A=84bug\n3.=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E5=AF=B9=E5=BA=8F=E5=88=97{S,B,C}=E8=A7=A3=E6=9E=90?= =?UTF-8?q?=E4=B8=BA=E5=B0=8F=E8=8A=82=E8=8A=82=E7=82=B9=E7=9A=84Parse,=20?= =?UTF-8?q?=E8=BF=99=E5=B0=86=E4=BC=9A=E4=BD=BF=E5=BE=97DDT=E4=B8=8EParse?= =?UTF-8?q?=E5=87=BD=E6=95=B0=E8=83=BD=E5=A4=9F=E9=80=9A=E8=BF=87bpm?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E5=B7=A5=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...{Convention-Unity.meta => Convention.meta} | 2 +- Assets/Scripts/Framework/DDT.cs | 16 +++++---- .../Framework/GameContent/GameController.cs | 5 +++ Assets/Scripts/Framework/ScriptableObject.cs | 34 ++++++++++++++++--- 4 files changed, 45 insertions(+), 12 deletions(-) rename Assets/{Convention-Unity.meta => Convention.meta} (77%) diff --git a/Assets/Convention-Unity.meta b/Assets/Convention.meta similarity index 77% rename from Assets/Convention-Unity.meta rename to Assets/Convention.meta index c52cba9..a10e9d3 100644 --- a/Assets/Convention-Unity.meta +++ b/Assets/Convention.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 0667b42895d3e8d49899aabe3006d732 +guid: 2b3ed32090a476b46b21bd207b4d2d34 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/Scripts/Framework/DDT.cs b/Assets/Scripts/Framework/DDT.cs index 3284a1a..bfdbda4 100644 --- a/Assets/Scripts/Framework/DDT.cs +++ b/Assets/Scripts/Framework/DDT.cs @@ -16,30 +16,34 @@ namespace Demo.Game public List Datas = new(); [ScriptableCall(@" -添加float数据, 随后可以用对象路径+索引获取变量值, +添加float数据(允许使用除本以外的表达式), 随后可以用对象路径+索引获取变量值, e.g: CameraObject/DDT[3], 获取CameraObject/DDT对象路径下DDT数据中的第四个值 ")] public void Add(string value) { - Datas.Add(float.Parse(value)); + Datas.Add(Parse(value)); } /// - /// 从特定的json中读取数据 + /// 从特定的json中读取数据, 并调用 /// - [ScriptableCall(@"从特定的json中读取数据")] + [ScriptableCall(@"从特定的json中读取数据, 并调用Add函数")] public void Load() { var file = new ToolFile(BindingDataJson); if (file.Exists() == false) { file.MustExistsPath() - .SaveAsJson>(new()); + .SaveAsJson>(new()); Datas.Clear(); } else { - Datas = file.LoadAsJson>(); + Datas.Clear(); + foreach (var item in file.LoadAsJson>()) + { + Add(item); + } } } } diff --git a/Assets/Scripts/Framework/GameContent/GameController.cs b/Assets/Scripts/Framework/GameContent/GameController.cs index 41a722f..a3a9fdd 100644 --- a/Assets/Scripts/Framework/GameContent/GameController.cs +++ b/Assets/Scripts/Framework/GameContent/GameController.cs @@ -80,7 +80,11 @@ namespace Demo.Game { IEnumerator Run() { +#if ENABLE_CLASS_Interaction var clipFile = new Interaction(clipPath); +#else + var clipFile = new ToolFile(clipPath); +#endif if (clipFile.Exists() == false) clipFile = new(MainConfig.GetFile(clipPath).GetFullPath()); if (clipFile.Exists() == false) @@ -109,6 +113,7 @@ namespace Demo.Game { ScriptableObject.FastScriptableObjectTypen = content.ScriptableObjectTypen; ScriptableObject.IsAutoPlay = content.IsAutoPlay; + ScriptableObject.OneBarTime = (float)MainConfig.FindItem(nameof(Editor.EditorController.BPM), Editor.EditorController.instance.BPM); SetupSongDuration = GameContent.instance.SetupSongDuration; SetSongCurrentTime = GameContent.instance.SetSongCurrentTime; SongOffset = GameContent.instance.SongOffset; diff --git a/Assets/Scripts/Framework/ScriptableObject.cs b/Assets/Scripts/Framework/ScriptableObject.cs index 301aa32..e37a3cb 100644 --- a/Assets/Scripts/Framework/ScriptableObject.cs +++ b/Assets/Scripts/Framework/ScriptableObject.cs @@ -269,6 +269,7 @@ namespace Demo // 数值解析工具 private readonly Dictionary DDTCache = new(); + public static float OneBarTime = 1; /// /// 从时间点列表中获取 @@ -287,15 +288,34 @@ namespace Demo return result; if(value.EndsWith(']')) { - Regex regex = new(@"^(.*)\[(\d)\]$"); - var match = regex.Match(value); - if (match.Success) { - if (FindWithPath(match.Groups[1].Value) is DDT ddt) + Regex regex = new(@"^(.+)\[(\d+)\]$"); + var match = regex.Match(value); + if (match.Success) { - return ddt.Datas[int.Parse(match.Groups[2].Value)]; + if (FindWithPath(match.Groups[1].Value) is DDT ddt) + { + DDTCache[match.Groups[1].Value] = ddt; + } + return DDTCache[match.Groups[1].Value].Datas[int.Parse(match.Groups[2].Value)]; } } + throw new ArgumentException("value is end by ']' but not match on any invlid parse"); + } + if (value.EndsWith('}')) + { + { + Regex regex = new(@"^\{\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\}$"); + var match = regex.Match(value); + if (match.Success) + { + int barSplitTimes = int.Parse(match.Groups[1].Value); + int barCount = int.Parse(match.Groups[2].Value); + int tickCount = int.Parse(match.Groups[3].Value); + return (barCount + tickCount / (float)barSplitTimes) * OneBarTime; + } + } + throw new ArgumentException("value is end by '}' but not match on any invlid parse"); } return float.Parse(value); } @@ -871,7 +891,11 @@ namespace Demo file = file | "Windows"; #endif file = file | ab; +#if ENABLE_CLASS_Interaction var downloader = new Interaction(file.GetFullPath()); +#else + var downloader = new ToolFile(file.GetFullPath()); +#endif if (AssetBundlesItemEntry == null) { var hierarchy = HierarchyWindow.instance;