mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 13:01:52 +00:00
Failed to show and edit script sctruct
+ SizeInBytes for MonoFields
This commit is contained in:
@@ -14,14 +14,16 @@ public struct ScriptField
|
||||
public bool IsStatic;
|
||||
public ScriptFieldType FieldType;
|
||||
public SharpType SharpType;
|
||||
public int SizeInBytes;
|
||||
|
||||
internal this(StringView name, MonoClassField* monoField, bool isStatic, ScriptFieldType fieldType, SharpType sharpType)
|
||||
internal this(StringView name, MonoClassField* monoField, bool isStatic, ScriptFieldType fieldType, int sizeInBytes, SharpType sharpType)
|
||||
{
|
||||
Name = name;
|
||||
_monoField = monoField;
|
||||
IsStatic = isStatic;
|
||||
FieldType = fieldType;
|
||||
SharpType = sharpType;
|
||||
SizeInBytes = sizeInBytes;
|
||||
}
|
||||
|
||||
public bool IsType(SharpClass otherClass, bool checkIfSubtype)
|
||||
@@ -173,7 +175,20 @@ class SharpClass : SharpType
|
||||
(attributes != null &&
|
||||
Mono.mono_custom_attrs_has_attr(attributes, ScriptEngine.Attributes.s_ShowInEditorAttribute)))
|
||||
{
|
||||
_monoFields[name] = .(name, currentField, flags.HasFlag(.Static), fieldType, sharpType);
|
||||
MonoClass* fieldClass = Mono.mono_type_get_class(type);
|
||||
|
||||
int sizeInBytes = 8;
|
||||
|
||||
if (fieldClass != null)
|
||||
{
|
||||
sizeInBytes = Mono.mono_class_instance_size(fieldClass);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
_monoFields[name] = .(name, currentField, flags.HasFlag(.Static), fieldType, sizeInBytes, sharpType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -514,10 +514,24 @@ static class ScriptEngine
|
||||
|
||||
Log.EngineLogger.AssertDebug(scriptClass != null);
|
||||
|
||||
for (let (fieldName, field) in scriptClass.Fields)
|
||||
void AddFieldsToMap(Dictionary<StringView, ScriptField> classFields, StringView baseName)
|
||||
{
|
||||
entityFields.Add(new String(fieldName), ScriptFieldInstance(field.FieldType));
|
||||
for (let (fieldName, field) in classFields)
|
||||
{
|
||||
/*if (field.FieldType == .Struct && field.SharpType != null)
|
||||
{
|
||||
AddFieldsToMap(field.SharpType.Fields, scope $"{baseName}{fieldName}.");
|
||||
}
|
||||
else
|
||||
{
|
||||
entityFields.Add(new $"{baseName}{fieldName}", ScriptFieldInstance(field.FieldType));
|
||||
}*/
|
||||
|
||||
entityFields.Add(new String(fieldName), ScriptFieldInstance(field.FieldType));
|
||||
}
|
||||
}
|
||||
|
||||
AddFieldsToMap(scriptClass.Fields, "");
|
||||
}
|
||||
|
||||
public static ScriptFieldMap GetScriptFieldMap(Entity entity)
|
||||
|
||||
Reference in New Issue
Block a user