Skip to content

Commit ed59b17

Browse files
committed
修复bug
1 parent a491d4d commit ed59b17

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Il2CppDumper/Outputs/ScriptGenerator.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,7 @@ private void AddFields(Il2CppTypeDefinition typeDef, StructInfo structInfo, Il2C
560560
if (typeDef.field_count > 0)
561561
{
562562
var fieldEnd = typeDef.fieldStart + typeDef.field_count;
563+
var cache = new HashSet<string>(StringComparer.Ordinal);
563564
for (var i = typeDef.fieldStart; i < fieldEnd; ++i)
564565
{
565566
var fieldDef = metadata.fieldDefs[i];
@@ -571,6 +572,10 @@ private void AddFields(Il2CppTypeDefinition typeDef, StructInfo structInfo, Il2C
571572
var structFieldInfo = new StructFieldInfo();
572573
structFieldInfo.FieldTypeName = ParseType(fieldType, context);
573574
var fieldName = FixName(metadata.GetStringFromIndex(fieldDef.nameIndex));
575+
if (!cache.Add(fieldName))
576+
{
577+
fieldName = $"_{i - typeDef.fieldStart}_{fieldName}";
578+
}
574579
structFieldInfo.FieldName = fieldName;
575580
structFieldInfo.IsValueType = IsValueType(fieldType, context);
576581
structFieldInfo.IsCustomType = IsCustomType(fieldType, context);

0 commit comments

Comments
 (0)