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())
|
foreach (var type in asm.GetTypes())
|
||||||
{
|
{
|
||||||
if (typeof(ScriptableObject).IsAssignableFrom(type) == false)
|
// Functions
|
||||||
continue;
|
if (typeof(ScriptableObject).IsAssignableFrom(type))
|
||||||
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",
|
var scriptCalls = (from info in type.GetMembers(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly)
|
||||||
_ => ".h"
|
where info is MethodInfo
|
||||||
};
|
where info.GetCustomAttribute<ScriptableCallAttribute>(false) != null
|
||||||
using var fs = File.AppendText((toolDir | fileHeader).GetFullPath());
|
select info as MethodInfo).ToList();
|
||||||
switch (style)
|
var typeName = type.Name;
|
||||||
{
|
if (typeName.Contains('`'))
|
||||||
case ProjectDefaultFileStyle.CPP:
|
{
|
||||||
WriteCPPClassBase(fs, type);
|
typeName = typeName[..typeName.LastIndexOf('`')];
|
||||||
break;
|
}
|
||||||
case ProjectDefaultFileStyle.PY:
|
string fileHeader = $"{typeName}.helper" + style switch
|
||||||
break;
|
{
|
||||||
}
|
ProjectDefaultFileStyle.PY => ",py",
|
||||||
foreach (var methodInfo in scriptCalls)
|
_ => ".h"
|
||||||
{
|
};
|
||||||
var data = methodInfo.GetCustomAttribute<ScriptableCallAttribute>(false);
|
using var fs = File.AppendText((toolDir | fileHeader).GetFullPath());
|
||||||
switch (style)
|
switch (style)
|
||||||
{
|
{
|
||||||
|
case ProjectDefaultFileStyle.CPP:
|
||||||
|
WriteCPPClassBase(fs, type);
|
||||||
|
break;
|
||||||
case ProjectDefaultFileStyle.PY:
|
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;
|
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))
|
if (Mathf.Approximately(durationX, durationY))
|
||||||
{
|
{
|
||||||
from = (durationX - clip.x) / left2rightDuration;
|
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
|
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
|
public static class ScriptCallUtility
|
||||||
{
|
{
|
||||||
// 解析函数调用的方法,支持 with 子句
|
// 解析函数调用的方法,支持 with 子句
|
||||||
|
|||||||
Reference in New Issue
Block a user