脚本缓存机制已经被添加
This commit is contained in:
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user