diff --git a/Assets/Scripts/Framework/EditiorContent/ProjectCreateHelper.cs b/Assets/Scripts/Framework/EditiorContent/ProjectCreateHelper.cs index 17f65bf..3dfc0b2 100644 --- a/Assets/Scripts/Framework/EditiorContent/ProjectCreateHelper.cs +++ b/Assets/Scripts/Framework/EditiorContent/ProjectCreateHelper.cs @@ -70,45 +70,52 @@ e.g: LoadSubScript(SplineCore, ""SplineCore.h"") with(r = 1, g = 1, b = 1); { foreach (var type in asm.GetTypes()) { - if (typeof(ScriptableObject).IsAssignableFrom(type) == false) - continue; - var scriptCalls = (from info in type.GetMembers(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly) - where info is MethodInfo - where info.GetCustomAttribute(false) != null - select info as MethodInfo).ToList(); - var typeName = type.Name; - if (typeName.Contains('`')) - { - typeName = typeName[..typeName.LastIndexOf('`')]; - } - string fileHeader = $"{typeName}.helper" + style switch + // Functions + if (typeof(ScriptableObject).IsAssignableFrom(type)) { - ProjectDefaultFileStyle.PY => ",py", - _ => ".h" - }; - using var fs = File.AppendText((toolDir | fileHeader).GetFullPath()); - switch (style) - { - case ProjectDefaultFileStyle.CPP: - WriteCPPClassBase(fs, type); - break; - case ProjectDefaultFileStyle.PY: - break; - } - foreach (var methodInfo in scriptCalls) - { - var data = methodInfo.GetCustomAttribute(false); + var scriptCalls = (from info in type.GetMembers(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly) + where info is MethodInfo + where info.GetCustomAttribute(false) != null + select info as MethodInfo).ToList(); + var typeName = type.Name; + if (typeName.Contains('`')) + { + typeName = typeName[..typeName.LastIndexOf('`')]; + } + string fileHeader = $"{typeName}.helper" + style switch + { + ProjectDefaultFileStyle.PY => ",py", + _ => ".h" + }; + using var fs = File.AppendText((toolDir | fileHeader).GetFullPath()); switch (style) { + case ProjectDefaultFileStyle.CPP: + WriteCPPClassBase(fs, type); + break; case ProjectDefaultFileStyle.PY: - WritePythonStyleFunction(fs, methodInfo.Name, from param in methodInfo.GetParameters() select param.Name, data.Description); - break; - default: - WriteCPPStyleFunction(fs, methodInfo.Name, from param in methodInfo.GetParameters() select param.Name, data.Description); break; } - } - } + foreach (var methodInfo in scriptCalls) + { + var data = methodInfo.GetCustomAttribute(false); + switch (style) + { + case ProjectDefaultFileStyle.PY: + WritePythonStyleFunction(fs, methodInfo.Name, from param in methodInfo.GetParameters() select param.Name, data.Description); + break; + default: + WriteCPPStyleFunction(fs, methodInfo.Name, from param in methodInfo.GetParameters() select param.Name, data.Description); + break; + } + } + } + // Enums + if (typeof(Enum).IsAssignableFrom(type)&& type.GetCustomAttribute(false) != null) + { + // TODO + } + } } } } diff --git a/Assets/Scripts/Framework/EditiorContent/TimelineItem.cs b/Assets/Scripts/Framework/EditiorContent/TimelineItem.cs index 3c54530..816f4aa 100644 --- a/Assets/Scripts/Framework/EditiorContent/TimelineItem.cs +++ b/Assets/Scripts/Framework/EditiorContent/TimelineItem.cs @@ -88,7 +88,7 @@ namespace Demo.Editor.UI if (Mathf.Approximately(durationX, durationY)) { from = (durationX - clip.x) / left2rightDuration; - to = Mathf.Max(from + 0.1f, EditorController.instance.SongOffset); + to = Mathf.Max(from + 0.1f, (EditorController.instance.SongOffset - clip.x) / left2rightDuration); } else { diff --git a/Assets/Scripts/Framework/ScriptableObject.cs b/Assets/Scripts/Framework/ScriptableObject.cs index 4f01187..51ec24c 100644 --- a/Assets/Scripts/Framework/ScriptableObject.cs +++ b/Assets/Scripts/Framework/ScriptableObject.cs @@ -30,6 +30,16 @@ namespace Demo } } + [System.AttributeUsage(AttributeTargets.Enum, Inherited = true, AllowMultiple = false)] + public sealed class ScriptableEnumAttribute : Attribute + { + public string Description; + public ScriptableEnumAttribute(string description) + { + this.Description = description; + } + } + public static class ScriptCallUtility { // 解析函数调用的方法,支持 with 子句