12 changed files with 164 additions and 63 deletions
@ -1,55 +0,0 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using Sirenix.Utilities; |
||||
|
||||
namespace Tools.ExcelResolver.Editor |
||||
{ |
||||
internal class ClassCodeData : IDisposable |
||||
{ |
||||
public TableType tableType; |
||||
public string className; |
||||
public FieldData[] fields; |
||||
public int[] keyIndex; |
||||
|
||||
public ClassCodeData(TableType tableType, string className) |
||||
{ |
||||
this.tableType = tableType; |
||||
this.className = $"{char.ToUpper(className[0])}{className.Substring(1)}"; |
||||
} |
||||
|
||||
public void Dispose() |
||||
{ |
||||
className = null; |
||||
fields.ForEach(field => field.Dispose()); |
||||
fields = null; |
||||
keyIndex = null; |
||||
} |
||||
} |
||||
|
||||
internal class FieldData : IDisposable |
||||
{ |
||||
public string varName; |
||||
public Type type; |
||||
public string info; |
||||
public string description; |
||||
public string path; |
||||
|
||||
public void Dispose() |
||||
{ |
||||
varName = null; |
||||
type = null; |
||||
info = null; |
||||
description = null; |
||||
path = null; |
||||
} |
||||
} |
||||
|
||||
internal enum TableType |
||||
{ |
||||
SingleKeyTable, // 单主键表 |
||||
UnionMultiKeyTable, // 多主键表(联合索引) |
||||
MultiKeyTable, // 多主键表(独立索引) |
||||
NotKetTable, // 无主键表 |
||||
ColumnTable, // 纵表 |
||||
} |
||||
} |
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2 |
||||
guid: de2816e4f3c947bf8c8292e2a4625987 |
||||
timeCreated: 1736064127 |
@ -0,0 +1,37 @@
|
||||
using System; |
||||
using System.Linq; |
||||
using Sirenix.Utilities; |
||||
|
||||
namespace Tools.ExcelResolver.Editor |
||||
{ |
||||
internal class ClassCodeData : IDisposable |
||||
{ |
||||
public TableType tableType; |
||||
public string className; |
||||
public FieldData[] fields; |
||||
public int[] keyIndex; |
||||
public FieldData[] keyField; |
||||
|
||||
public ClassCodeData(TableType tableType, string className, FieldData[] fields, int[] keyIndex) |
||||
{ |
||||
this.tableType = tableType; |
||||
this.className = $"{char.ToUpper(className[0])}{className.Substring(1)}"; |
||||
this.fields = fields; |
||||
this.keyIndex = keyIndex; |
||||
|
||||
keyField = new FieldData[keyIndex.Length]; |
||||
for (int i = 0; i < keyIndex.Length; i++) |
||||
{ |
||||
keyField[i] = fields.First(f => f.colIndex == keyIndex[i]); |
||||
} |
||||
} |
||||
|
||||
public void Dispose() |
||||
{ |
||||
className = null; |
||||
fields.ForEach(field => field.Dispose()); |
||||
fields = null; |
||||
keyIndex = null; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,44 @@
|
||||
using System; |
||||
using System.CodeDom; |
||||
|
||||
namespace Tools.ExcelResolver.Editor |
||||
{ |
||||
internal class FieldData : IDisposable |
||||
{ |
||||
public int colIndex; |
||||
|
||||
public string varName; |
||||
public string typeString; |
||||
public Type type; |
||||
public string info; |
||||
public string description; |
||||
public string path; |
||||
|
||||
public void Dispose() |
||||
{ |
||||
varName = null; |
||||
type = null; |
||||
info = null; |
||||
description = null; |
||||
path = null; |
||||
} |
||||
} |
||||
|
||||
internal static class FieldDataExtension |
||||
{ |
||||
internal static CodeMemberField GetCodeField(this FieldData field) |
||||
{ |
||||
CodeMemberField codeField = new CodeMemberField |
||||
{ |
||||
Attributes = MemberAttributes.Public, |
||||
Name = field.varName, |
||||
Type = new CodeTypeReference(field.type), |
||||
CustomAttributes = new CodeAttributeDeclarationCollection() |
||||
{ |
||||
new CodeAttributeDeclaration("SerializeField") |
||||
}, |
||||
}; |
||||
return codeField; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 148e616320e64bf8bf00bd7246c111cd |
||||
timeCreated: 1736064103 |
@ -0,0 +1,11 @@
|
||||
namespace Tools.ExcelResolver.Editor |
||||
{ |
||||
internal enum TableType |
||||
{ |
||||
SingleKeyTable, // 单主键表 |
||||
UnionMultiKeyTable, // 多主键表(联合索引) |
||||
MultiKeyTable, // 多主键表(独立索引) |
||||
NotKetTable, // 无主键表 |
||||
ColumnTable, // 纵表 |
||||
} |
||||
} |
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 26412086a14b46d48ae049ed45c53010 |
||||
timeCreated: 1736064144 |
@ -0,0 +1,15 @@
|
||||
using UnityEditor; |
||||
using UnityEngine; |
||||
|
||||
namespace Tools.ExcelResolver.Editor |
||||
{ |
||||
public sealed partial class ExcelResolverEditorWindow |
||||
{ |
||||
private void CreateSO(ClassCodeData classCodeData) |
||||
{ |
||||
var so = ScriptableObject.CreateInstance(classCodeData.className + "SO"); |
||||
AssetDatabase.CreateAsset(so, $"{excelResolverConfig.SOPathRoot}/{classCodeData.className}SO.asset"); |
||||
AssetDatabase.SaveAssets(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2 |
||||
guid: 6236e2a00de94de2b8e6aff5ac5c7745 |
||||
timeCreated: 1736066833 |
Loading…
Reference in new issue