From c80d5140bc319b47ba1f8e6463f13f69a946b4bd Mon Sep 17 00:00:00 2001 From: ninemine <1371605831@qq.com> Date: Wed, 3 Dec 2025 14:37:12 +0800 Subject: [PATCH] =?UTF-8?q?=E8=84=9A=E6=9C=AC=E7=BC=93=E5=AD=98=E6=9C=BA?= =?UTF-8?q?=E5=88=B6=E5=B7=B2=E7=BB=8F=E8=A2=AB=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Convention | 2 +- .../Framework/GameContent/GameController.cs | 2 +- Assets/Scripts/Framework/ScriptableObject.cs | 151 +-------- .../DefaultScriptableObjectInstantiate.cs | 314 ++++++++++++++++-- Assets/Scripts/Framework/[RScript] | 2 +- 5 files changed, 284 insertions(+), 187 deletions(-) diff --git a/Assets/Convention b/Assets/Convention index 48965de..8e419a3 160000 --- a/Assets/Convention +++ b/Assets/Convention @@ -1 +1 @@ -Subproject commit 48965decbba06bb4071479ae7f428ee3a89907ce +Subproject commit 8e419a32572d8991e12babcd7d3a2240aac810f3 diff --git a/Assets/Scripts/Framework/GameContent/GameController.cs b/Assets/Scripts/Framework/GameContent/GameController.cs index 6e2d476..9019aa2 100644 --- a/Assets/Scripts/Framework/GameContent/GameController.cs +++ b/Assets/Scripts/Framework/GameContent/GameController.cs @@ -220,7 +220,7 @@ namespace Demo.Game rootGameObject.SetContent(nameof(SongOffset), SongOffset); rootGameObject.SetContent(nameof(IsAutoPlay), IsAutoPlay ? 1 : 0); rootGameObject.SetContent("SongLength", MainAudio.CurrentClip.length); - yield return rootGameObject.ParseScript2Expr(rootObject.LoadAsText()); + yield return rootGameObject.ParseFromScriptFile2Expr(rootObject); static void NDFS(ScriptableObject current) { foreach (var child in current.Childs) diff --git a/Assets/Scripts/Framework/ScriptableObject.cs b/Assets/Scripts/Framework/ScriptableObject.cs index 3638dbc..0b8cbe1 100644 --- a/Assets/Scripts/Framework/ScriptableObject.cs +++ b/Assets/Scripts/Framework/ScriptableObject.cs @@ -21,81 +21,6 @@ namespace Demo #region ScriptableObject Inside - namespace PrivateType - { - public class EaseCurveTypeInstance - { - public static EaseCurveTypeInstance instance = new(); - public MathExtension.EaseCurveType Linear => MathExtension.EaseCurveType.Linear; - public MathExtension.EaseCurveType InQuad => MathExtension.EaseCurveType.InQuad; - public MathExtension.EaseCurveType OutQuad => MathExtension.EaseCurveType.OutQuad; - public MathExtension.EaseCurveType InOutQuad => MathExtension.EaseCurveType.InOutQuad; - public MathExtension.EaseCurveType InCubic => MathExtension.EaseCurveType.InCubic; - public MathExtension.EaseCurveType OutCubic => MathExtension.EaseCurveType.OutCubic; - public MathExtension.EaseCurveType InOutCubic => MathExtension.EaseCurveType.InOutCubic; - public MathExtension.EaseCurveType InQuart => MathExtension.EaseCurveType.InQuart; - public MathExtension.EaseCurveType OutQuart => MathExtension.EaseCurveType.OutQuart; - public MathExtension.EaseCurveType InOutQuart => MathExtension.EaseCurveType.InOutQuart; - public MathExtension.EaseCurveType InQuint => MathExtension.EaseCurveType.InQuint; - public MathExtension.EaseCurveType OutQuint => MathExtension.EaseCurveType.OutQuint; - public MathExtension.EaseCurveType InOutQuint => MathExtension.EaseCurveType.InOutQuint; - public MathExtension.EaseCurveType InSine => MathExtension.EaseCurveType.InSine; - public MathExtension.EaseCurveType OutSine => MathExtension.EaseCurveType.OutSine; - public MathExtension.EaseCurveType InOutSine => MathExtension.EaseCurveType.InOutSine; - public MathExtension.EaseCurveType InExpo => MathExtension.EaseCurveType.InExpo; - public MathExtension.EaseCurveType OutExpo => MathExtension.EaseCurveType.OutExpo; - public MathExtension.EaseCurveType InOutExpo => MathExtension.EaseCurveType.InOutExpo; - public MathExtension.EaseCurveType InCirc => MathExtension.EaseCurveType.InCirc; - public MathExtension.EaseCurveType OutCirc => MathExtension.EaseCurveType.OutCirc; - public MathExtension.EaseCurveType InOutCirc => MathExtension.EaseCurveType.InOutCirc; - public MathExtension.EaseCurveType InBounce => MathExtension.EaseCurveType.InBounce; - public MathExtension.EaseCurveType OutBounce => MathExtension.EaseCurveType.OutBounce; - public MathExtension.EaseCurveType InOutBounce => MathExtension.EaseCurveType.InOutBounce; - public MathExtension.EaseCurveType InElastic => MathExtension.EaseCurveType.InElastic; - public MathExtension.EaseCurveType OutElastic => MathExtension.EaseCurveType.OutElastic; - public MathExtension.EaseCurveType InOutElastic => MathExtension.EaseCurveType.InOutElastic; - public MathExtension.EaseCurveType InBack => MathExtension.EaseCurveType.InBack; - public MathExtension.EaseCurveType OutBack => MathExtension.EaseCurveType.OutBack; - public MathExtension.EaseCurveType InOutBack => MathExtension.EaseCurveType.InOutBack; - public MathExtension.EaseCurveType Custom => MathExtension.EaseCurveType.Custom; - } - - public class SplineComputerSampleModeInstance - { - public static SplineComputerSampleModeInstance instance = new(); - public SplineComputer.SampleMode Default => SplineComputer.SampleMode.Default; - public SplineComputer.SampleMode Uniform => SplineComputer.SampleMode.Uniform; - public SplineComputer.SampleMode Optimized => SplineComputer.SampleMode.Optimized; - } - - public class SplineTypeInstance - { - public static SplineTypeInstance instance = new(); - public Spline.Type Linear => Spline.Type.Linear; - public Spline.Type BSpline => Spline.Type.BSpline; - public Spline.Type CatmullRom => Spline.Type.CatmullRom; - public Spline.Type Bezier => Spline.Type.Bezier; - } - - public class IEffectHookObjectInstance - { - public static IEffectHookObjectInstance instance = new(); - public IEffectHookObject.InteractiveEffectType VisibleDuration => IEffectHookObject.InteractiveEffectType.VisibleDuration; - public IEffectHookObject.InteractiveEffectType InteractiveDuration => IEffectHookObject.InteractiveEffectType.InteractiveDuration; - public IEffectHookObject.InteractiveEffectType InteractableScoreInterval => IEffectHookObject.InteractiveEffectType.InteractableScoreInterval; - public IEffectHookObject.InteractiveEffectType InteractableIntervalThatCanScoreBest => IEffectHookObject.InteractiveEffectType.InteractableIntervalThatCanScoreBest; - } - - public class IInteractionJudgementLevelInstance - { - public static IInteractionJudgementLevelInstance instance = new(); - public IInteraction.JudgementLevel Bad => IInteraction.JudgementLevel.Bad; - public IInteraction.JudgementLevel ScoreLevel => IInteraction.JudgementLevel.ScoreLevel; - public IInteraction.JudgementLevel None => IInteraction.JudgementLevel.None; - public IInteraction.JudgementLevel BestLevel => IInteraction.JudgementLevel.BestLevel; - } - } - public partial class ScriptableObject : IScriptableObject { /// @@ -351,7 +276,6 @@ namespace Demo public PropertiesWindow.ItemEntry MyHierarchyItem; public static PropertiesWindow.ItemEntry AllScriptableObjectCounterHierarchyItem; - public static PropertiesWindow.ItemEntry ScriptParseingHierarchyItem; public bool EnsureEnableScript() { @@ -414,7 +338,7 @@ namespace Demo Childs.Add(child); // Load Child Script - ConventionUtility.StartCoroutine(child.ParseScript2Expr(file.LoadAsText())); + ConventionUtility.StartCoroutine(child.ParseFromScriptFile2Expr(file)); return child; } @@ -470,79 +394,6 @@ namespace Demo #endregion - public static class RandomTool - { - public static float Random(float min, float max) - { - return UnityEngine.Random.Range(min, max); - } - - public static float Random(double min, double max) - { - return UnityEngine.Random.Range((float)min, (float)max); - } - } - - public class ConsoleTool - { - private GameObject gameObject; - public ConsoleTool(GameObject gameObject) - { - this.gameObject = gameObject; - } - - public void Log(object obj) - { - Debug.Log(obj, gameObject); - } - } - - private static readonly object ParseScript2ExprObjectLocker = new(); - public IEnumerator ParseScript2Expr(string script) - { - IsParseScript2Expr = true; - try - { - RScriptEngine engine = new(); - RScriptImportClass importClass = new() - { - typeof(Mathf), - typeof(RandomTool), - }; - RScriptVariables variables = new() - { - { "this", new() { data = this, type = this.GetType() } }, - { "self", new() { data = this, type = this.GetType() } }, - { "console", new() { data = new ConsoleTool(gameObject), type = typeof(ConsoleTool) } }, - { nameof(MathExtension.EaseCurveType), new() { data = PrivateType.EaseCurveTypeInstance.instance, type = typeof(PrivateType.EaseCurveTypeInstance) } }, - { $"Spline{nameof(SplineComputer.SampleMode)}", - new() { data = PrivateType.SplineComputerSampleModeInstance.instance, type = typeof(PrivateType.SplineComputerSampleModeInstance)} }, - { $"Spline{nameof(Spline.Type)}", - new() { data = PrivateType.SplineTypeInstance.instance, type = typeof(PrivateType.SplineTypeInstance)} }, - { nameof(IEffectHookObject.InteractiveEffectType), - new() { data = PrivateType.IEffectHookObjectInstance.instance, type = typeof(PrivateType.IEffectHookObjectInstance)} }, - { nameof(IInteraction.JudgementLevel), - new() { data = PrivateType.IInteractionJudgementLevelInstance.instance, type = typeof(PrivateType.IInteractionJudgementLevelInstance) } } - }; - - if (ScriptParseingHierarchyItem == null) - { - ScriptParseingHierarchyItem = HierarchyWindow.instance.CreateRootItemEntryWithBinders(ParseScript2ExprObjectLocker)[0]; - } - - foreach (var ir in engine.RunAsync(script, importClass, variables).Yield()) - { - yield return ir; - if (engine.context.CurrentRuntimePointer < engine.context.Sentences.Length) - ScriptParseingHierarchyItem.GetHierarchyItem().title = engine.context.CurrentSentence.ToString(); - } - } - finally - { - IsParseScript2Expr = false; - } - } - public enum TickType { Reset, diff --git a/Assets/Scripts/Framework/ScriptableObjectInstantiate/DefaultScriptableObjectInstantiate.cs b/Assets/Scripts/Framework/ScriptableObjectInstantiate/DefaultScriptableObjectInstantiate.cs index 35b9e2d..f1289c7 100644 --- a/Assets/Scripts/Framework/ScriptableObjectInstantiate/DefaultScriptableObjectInstantiate.cs +++ b/Assets/Scripts/Framework/ScriptableObjectInstantiate/DefaultScriptableObjectInstantiate.cs @@ -1,19 +1,24 @@ +using Convention; +using Convention.RScript; +using Convention.WindowsUI.Variant; +using Demo.Game; +using Demo.PrivateType; +using Dreamteck.Splines; using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; -using Convention; -using Convention.WindowsUI.Variant; -using Dreamteck.Splines; using UnityEngine; -namespace Demo.Game +namespace Demo { - public static class DefaultInstantiate + namespace Game { - public static Dictionary> GameObjectInstantiate = new() + public static class DefaultInstantiate { + public static Dictionary> GameObjectInstantiate = new() + { { $"{nameof(Anchor)}",Anchor.Make}, // Camera { $"{nameof(CameraObject)}",CameraObject.MakeCameraObject}, @@ -22,30 +27,30 @@ namespace Demo.Game { $"{nameof(SkyUpdatement)}",SkyUpdatement.Make}, // Sub World { $"{nameof(SubWorld)}",SubWorld.Make}, - }; + }; - public static Dictionary> DDTInstantiate = new() - { + public static Dictionary> DDTInstantiate = new() + { { $"{nameof(DDT)}",DDT.Make} - }; + }; - public static Dictionary> TickUpdatementInstantiate = new () - { + public static Dictionary> TickUpdatementInstantiate = new() + { { $"{nameof(LookAtAnchor)}",LookAtAnchor.Make}, { $"{nameof(TickMovement)}",TickMovement.Make}, { $"{nameof(TickRotation)}",TickRotation.Make}, { $"{nameof(TickScaling)}",TickScaling.Make}, - }; + }; - public static Dictionary> MaterialUpdatementInstantiate = new() - { + public static Dictionary> MaterialUpdatementInstantiate = new() + { { $"{nameof(MaterialUpdatement)}",MaterialUpdatement.Make}, { $"{nameof(ColorUpdatement)}",ColorUpdatement.Make}, { $"{nameof(EmissionColorUpdatement)}",EmissionColorUpdatement.Make}, - }; + }; - public static Dictionary> SplineInstantiate = new() - { + public static Dictionary> SplineInstantiate = new() + { { $"{nameof(SplineCore)}",SplineCore.Make}, { $"{nameof(SplineNode)}",SplineNode.Make}, { $"{nameof(SplineAnchor)}",SplineAnchor.Make}, @@ -56,22 +61,22 @@ namespace Demo.Game { $"{nameof(SplineTrackRenderer)}",SplineTrackRenderer.Make}, { $"{nameof(SplineTubeRenderer)}",SplineTubeRenderer.Make}, { $"{nameof(SplineSurfaceRenderer)}",SplineSurfaceRenderer.Make}, - }; + }; - public static Dictionary> JudgementInstantiate = new() - { + public static Dictionary> JudgementInstantiate = new() + { // 可判定物只能有一个种类被使用,否则会引起输入检定冲突 { $"{nameof(FullScreenInteraction)}",FullScreenInteraction.Make}, // Effect { $"{nameof(ParticleEffect)}",ParticleEffect.Make }, // JudgementEffect { $"{nameof(ParticleJudgement)}",ParticleJudgement.Make}, - }; + }; - public static void OpenInstantiateMenu(this ScriptableObject self, RectTransform item) - { - List result = new() + public static void OpenInstantiateMenu(this ScriptableObject self, RectTransform item) { + List result = new() + { // Show Name new($"{self.ScriptName}",_=>{ }), new($"{self.GetType()}",_=>{ }), @@ -80,18 +85,259 @@ namespace Demo.Game new($"Angles:{self.transform.eulerAngles}",_=>{ }), new($"xAngles:{self.transform.localEulerAngles}",_=>{ }), new($"Scale:{self.transform.localScale}",_=>{ }), - }; - SharedModule.instance.OpenCustomMenu(item, result.ToArray()); + }; + SharedModule.instance.OpenCustomMenu(item, result.ToArray()); + } + + public static Dictionary> GetScriptableObjectInstantiate() + { + return new Dictionary>(GameObjectInstantiate + .Union(DDTInstantiate) + .Union(TickUpdatementInstantiate) + .Union(MaterialUpdatementInstantiate) + .Union(SplineInstantiate) + .Union(JudgementInstantiate)); + } + } + } + + namespace PrivateType + { + public class EaseCurveTypeInstance + { + public static EaseCurveTypeInstance instance = new(); + public MathExtension.EaseCurveType Linear => MathExtension.EaseCurveType.Linear; + public MathExtension.EaseCurveType InQuad => MathExtension.EaseCurveType.InQuad; + public MathExtension.EaseCurveType OutQuad => MathExtension.EaseCurveType.OutQuad; + public MathExtension.EaseCurveType InOutQuad => MathExtension.EaseCurveType.InOutQuad; + public MathExtension.EaseCurveType InCubic => MathExtension.EaseCurveType.InCubic; + public MathExtension.EaseCurveType OutCubic => MathExtension.EaseCurveType.OutCubic; + public MathExtension.EaseCurveType InOutCubic => MathExtension.EaseCurveType.InOutCubic; + public MathExtension.EaseCurveType InQuart => MathExtension.EaseCurveType.InQuart; + public MathExtension.EaseCurveType OutQuart => MathExtension.EaseCurveType.OutQuart; + public MathExtension.EaseCurveType InOutQuart => MathExtension.EaseCurveType.InOutQuart; + public MathExtension.EaseCurveType InQuint => MathExtension.EaseCurveType.InQuint; + public MathExtension.EaseCurveType OutQuint => MathExtension.EaseCurveType.OutQuint; + public MathExtension.EaseCurveType InOutQuint => MathExtension.EaseCurveType.InOutQuint; + public MathExtension.EaseCurveType InSine => MathExtension.EaseCurveType.InSine; + public MathExtension.EaseCurveType OutSine => MathExtension.EaseCurveType.OutSine; + public MathExtension.EaseCurveType InOutSine => MathExtension.EaseCurveType.InOutSine; + public MathExtension.EaseCurveType InExpo => MathExtension.EaseCurveType.InExpo; + public MathExtension.EaseCurveType OutExpo => MathExtension.EaseCurveType.OutExpo; + public MathExtension.EaseCurveType InOutExpo => MathExtension.EaseCurveType.InOutExpo; + public MathExtension.EaseCurveType InCirc => MathExtension.EaseCurveType.InCirc; + public MathExtension.EaseCurveType OutCirc => MathExtension.EaseCurveType.OutCirc; + public MathExtension.EaseCurveType InOutCirc => MathExtension.EaseCurveType.InOutCirc; + public MathExtension.EaseCurveType InBounce => MathExtension.EaseCurveType.InBounce; + public MathExtension.EaseCurveType OutBounce => MathExtension.EaseCurveType.OutBounce; + public MathExtension.EaseCurveType InOutBounce => MathExtension.EaseCurveType.InOutBounce; + public MathExtension.EaseCurveType InElastic => MathExtension.EaseCurveType.InElastic; + public MathExtension.EaseCurveType OutElastic => MathExtension.EaseCurveType.OutElastic; + public MathExtension.EaseCurveType InOutElastic => MathExtension.EaseCurveType.InOutElastic; + public MathExtension.EaseCurveType InBack => MathExtension.EaseCurveType.InBack; + public MathExtension.EaseCurveType OutBack => MathExtension.EaseCurveType.OutBack; + public MathExtension.EaseCurveType InOutBack => MathExtension.EaseCurveType.InOutBack; + public MathExtension.EaseCurveType Custom => MathExtension.EaseCurveType.Custom; } - public static Dictionary> GetScriptableObjectInstantiate() + public class SplineComputerSampleModeInstance { - return new Dictionary>(GameObjectInstantiate - .Union(DDTInstantiate) - .Union(TickUpdatementInstantiate) - .Union(MaterialUpdatementInstantiate) - .Union(SplineInstantiate) - .Union(JudgementInstantiate)); + public static SplineComputerSampleModeInstance instance = new(); + public SplineComputer.SampleMode Default => SplineComputer.SampleMode.Default; + public SplineComputer.SampleMode Uniform => SplineComputer.SampleMode.Uniform; + public SplineComputer.SampleMode Optimized => SplineComputer.SampleMode.Optimized; + } + + public class SplineTypeInstance + { + public static SplineTypeInstance instance = new(); + public Spline.Type Linear => Spline.Type.Linear; + public Spline.Type BSpline => Spline.Type.BSpline; + public Spline.Type CatmullRom => Spline.Type.CatmullRom; + public Spline.Type Bezier => Spline.Type.Bezier; + } + + public class IEffectHookObjectInstance + { + public static IEffectHookObjectInstance instance = new(); + public IEffectHookObject.InteractiveEffectType VisibleDuration => IEffectHookObject.InteractiveEffectType.VisibleDuration; + public IEffectHookObject.InteractiveEffectType InteractiveDuration => IEffectHookObject.InteractiveEffectType.InteractiveDuration; + public IEffectHookObject.InteractiveEffectType InteractableScoreInterval => IEffectHookObject.InteractiveEffectType.InteractableScoreInterval; + public IEffectHookObject.InteractiveEffectType InteractableIntervalThatCanScoreBest => IEffectHookObject.InteractiveEffectType.InteractableIntervalThatCanScoreBest; + } + + public class IInteractionJudgementLevelInstance + { + public static IInteractionJudgementLevelInstance instance = new(); + public IInteraction.JudgementLevel Bad => IInteraction.JudgementLevel.Bad; + public IInteraction.JudgementLevel ScoreLevel => IInteraction.JudgementLevel.ScoreLevel; + public IInteraction.JudgementLevel None => IInteraction.JudgementLevel.None; + public IInteraction.JudgementLevel BestLevel => IInteraction.JudgementLevel.BestLevel; + } + + public static class RandomTool + { + public static float Random(float min, float max) + { + return UnityEngine.Random.Range(min, max); + } + + public static float Random(double min, double max) + { + return UnityEngine.Random.Range((float)min, (float)max); + } + } + + public class ConsoleTool + { + private GameObject gameObject; + public ConsoleTool(GameObject gameObject) + { + this.gameObject = gameObject; + } + + public void Log(object obj) + { + Debug.Log(obj, gameObject); + } + } + } + + public partial class ScriptableObject + { + protected virtual bool IsImptSerialize => false; + protected virtual void LoadFromImptCacheFile(ToolFile file) + { + throw new NotImplementedException(); + } + protected virtual void CreateAndLoadingImptCacheFile(ToolFile file) + { + throw new NotImplementedException(); + } + + public RScriptImportClass GenerateImport() + { + RScriptImportClass importClass = new() + { + typeof(Mathf), + typeof(RandomTool), + }; + return importClass; + } + + public RScriptVariables GenerateVariables() + { + RScriptVariables variables = new() + { + { "this", new() { data = this, type = this.GetType() } }, + { "self", new() { data = this, type = this.GetType() } }, + { "console", new() { data = new ConsoleTool(gameObject), type = typeof(ConsoleTool) } }, + { nameof(MathExtension.EaseCurveType), new() { data = EaseCurveTypeInstance.instance, type = typeof(EaseCurveTypeInstance) } }, + { $"Spline{nameof(SplineComputer.SampleMode)}", + new() { data = SplineComputerSampleModeInstance.instance, type = typeof(SplineComputerSampleModeInstance)} }, + { $"Spline{nameof(Spline.Type)}", + new() { data = SplineTypeInstance.instance, type = typeof(SplineTypeInstance)} }, + { nameof(IEffectHookObject.InteractiveEffectType), + new() { data = IEffectHookObjectInstance.instance, type = typeof(IEffectHookObjectInstance)} }, + { nameof(IInteraction.JudgementLevel), + new() { data = IInteractionJudgementLevelInstance.instance, type = typeof(IInteractionJudgementLevelInstance) } } + }; + return variables; + } + + private static readonly Dictionary s_FileLocker = new(); + + public IEnumerator ParseFromScriptFile2Expr(ToolFile file) + { + IsParseScript2Expr = true; + try + { + var hash = file.CalculateHash(); + var lastHashFile = file.GetParentDir() | ".cache" | $"{file.GetFilename(true)}.hash"; + var bin = file.GetParentDir() | ".cache" | $"{file.GetFilename(true)}.bin"; + if (IsImptSerialize) + { + if (lastHashFile.Exists() == false || lastHashFile.LoadAsText() != hash) + { + lastHashFile.MustExistsPath(); + lastHashFile.SaveAsText(hash); + CreateAndLoadingImptCacheFile(bin); + } + else + { + LoadFromImptCacheFile(bin); + } + } + else + { + RScriptEngine engine = new(); + RScriptImportClass importClass = GenerateImport(); + RScriptVariables variables = GenerateVariables(); + object locker; + IEnumerator step = null; + if (lastHashFile.Exists() == false || lastHashFile.LoadAsText() != hash) + { + lastHashFile.MustExistsPath(); + bin.MustExistsPath(); + lastHashFile.SaveAsText(hash); + var script = file.LoadAsText(); + + var structBin = engine.Compile(script, importClass, variables); + lock (s_FileLocker) + { + if (s_FileLocker.TryGetValue(file.GetFullPath(), out locker) == false) + { + s_FileLocker.Add(file.GetFullPath(), locker = new object()); + } + } + lock (locker) + { + bin.SaveAsBinary(RScriptSerializer.SerializeClass(structBin)); + } + step = engine.RunAsync(script, importClass, variables); + } + else + { + RScriptContext.SerializableClass structBin; + lock (s_FileLocker) + { + if (s_FileLocker.TryGetValue(file.GetFullPath(), out locker) == false) + { + s_FileLocker.Add(file.GetFullPath(), locker = new object()); + } + } + lock (locker) + { + structBin = RScriptSerializer.DeserializeClass(bin.LoadAsBinary()); + } + step = engine.RunAsync(structBin, importClass, variables); + + } + yield return step; + } + } + finally + { + IsParseScript2Expr = false; + } + } + + public IEnumerator ParseScript2Expr(string script) + { + IsParseScript2Expr = true; + try + { + RScriptEngine engine = new(); + RScriptImportClass importClass = GenerateImport(); + RScriptVariables variables = GenerateVariables(); + + var step = engine.RunAsync(script, importClass, variables); + yield return step; + } + finally + { + IsParseScript2Expr = false; + } } } } diff --git a/Assets/Scripts/Framework/[RScript] b/Assets/Scripts/Framework/[RScript] index cdf04ac..02906f8 160000 --- a/Assets/Scripts/Framework/[RScript] +++ b/Assets/Scripts/Framework/[RScript] @@ -1 +1 @@ -Subproject commit cdf04acecf07326cd3e155a8b4ecbf9479c6f4b9 +Subproject commit 02906f836db6481d6da5c5bf0a4da7575bbf5685