1.准备编写ScriptableEnum的Helper2.准备Judgement的快速创建体系
This commit is contained in:
@@ -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<ScriptableCallAttribute>(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<ScriptableCallAttribute>(false);
|
||||
var scriptCalls = (from info in type.GetMembers(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly)
|
||||
where info is MethodInfo
|
||||
where info.GetCustomAttribute<ScriptableCallAttribute>(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<ScriptableCallAttribute>(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<ScriptableCallAttribute>(false) != null)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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 子句
|
||||
|
||||
Reference in New Issue
Block a user