完成Note预制体的创建体系
This commit is contained in:
@@ -4,8 +4,6 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Convention;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Demo.Editor
|
||||
{
|
||||
@@ -20,42 +18,56 @@ namespace Demo.Editor
|
||||
private static void WriteCPPClassBase(StreamWriter stream, Type currentType)
|
||||
{
|
||||
if (currentType == typeof(ScriptableObject))
|
||||
return;
|
||||
string typeName = currentType.Name;
|
||||
if (typeName.Contains('`'))
|
||||
{
|
||||
typeName = typeName[..typeName.LastIndexOf('`')];
|
||||
|
||||
foreach (var asm in AppDomain.CurrentDomain.GetAssemblies())
|
||||
{
|
||||
foreach (var type in asm.GetTypes())
|
||||
{
|
||||
// Functions
|
||||
if (typeof(ScriptableObject).IsAssignableFrom(type))
|
||||
{
|
||||
string typeName = type.Name;
|
||||
if (typeName.Contains('`'))
|
||||
{
|
||||
typeName = typeName[..typeName.LastIndexOf('`')];
|
||||
}
|
||||
stream.WriteLine($"#define {typeName}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stream.Write(@"/*
|
||||
<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ
|
||||
e.g: LoadSubScript(SplineCore, ""SplineCore.h"") with(r = 1, g = 1, b = 1);
|
||||
*/");
|
||||
stream.Write($"#define with(...)\n\n");
|
||||
return;
|
||||
}
|
||||
string baseTypeName = currentType.BaseType.Name;
|
||||
if (baseTypeName.Contains('`'))
|
||||
{
|
||||
baseTypeName = baseTypeName[..baseTypeName.LastIndexOf('`')];
|
||||
}
|
||||
stream.Write($"#include \"{baseTypeName}.helper.h\"\n\n#define {typeName}\n\n");
|
||||
stream.Write(@"/*
|
||||
<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ
|
||||
e.g: LoadSubScript(SplineCore, ""SplineCore.h"") with(r = 1, g = 1, b = 1);
|
||||
*/");
|
||||
stream.Write($"#define with(...)\n\n");
|
||||
|
||||
stream.Write($"#include \"{baseTypeName}.helper.h\"\n\n");
|
||||
}
|
||||
|
||||
private static void WriteCPPStyleFunction(StreamWriter stream, string name, IEnumerable<string> paramList, string description)
|
||||
{
|
||||
if (name == nameof(ScriptableObject.LoadSubScript))
|
||||
{
|
||||
if (name == nameof(ScriptableObject.LoadSubScript))
|
||||
{
|
||||
stream.WriteLine("#define __build_in_pragma #");
|
||||
stream.WriteLine("#define __build_in_to_text(x) #x");
|
||||
|
||||
stream.Write("/*\n" + description + "\n*/\n");
|
||||
stream.Write($"#define {name}({string.Join(',', paramList)}) __build_in_pragma include {paramList.ToArray()[1]}\n\n");
|
||||
//stream.Write($"#define {name}({string.Join(',', paramList)})\n\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
stream.Write("/*\n" + description + "\n*/\n");
|
||||
stream.Write($"#define {name}({string.Join(',', paramList)}) \n\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
stream.Write("/*\n" + description + "\n*/\n");
|
||||
stream.Write($"#define {name}({string.Join(',', paramList)}) \n\n");
|
||||
}
|
||||
}
|
||||
|
||||
public static void CreateHelperFiles(string dir, ProjectDefaultFileStyle style = ProjectDefaultFileStyle.CPP)
|
||||
|
||||
Reference in New Issue
Block a user