Skip to content

Commit

Permalink
properly get all fields
Browse files Browse the repository at this point in the history
A
  • Loading branch information
Eddio0141 committed Nov 10, 2024
1 parent 7db4ac0 commit bfe3362
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion UniTAS/Patcher/Implementations/Movie/Parser/MovieParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ private void AddUnityTypes()
continue;
}

var fields = AccessTools.GetDeclaredFields(monoBehaviour);
var fields = monoBehaviour.GetFields(AccessTools.all);
foreach (var field in fields)
{
desc.AddMember(field.Name, new ReadOnlyFieldDescriptor(field, InteropAccessMode.Default));
Expand Down
6 changes: 3 additions & 3 deletions UniTAS/Patcher/Implementations/Serialization/Serializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public IEnumerable<SerializedData> SerializeStaticFields(Type targetClass,
throw new ArgumentNullException(nameof(targetClass));
}

return AccessTools.GetDeclaredFields(targetClass).Where(x => x.IsStatic && !x.IsLiteral)
return targetClass.GetFields(AccessTools.all).Where(x => x.IsStatic && !x.IsLiteral)
.Select(x => SerializeField(targetClass.FullName, x, null, references));
}

Expand Down Expand Up @@ -59,7 +59,7 @@ private static SerializedData SerializeField(string className, FieldInfo field,
return new(className, field.Name, newReferenceId);
}

var fields = AccessTools.GetDeclaredFields(value.GetType()).Where(x => !x.IsStatic && !x.IsLiteral)
var fields = value.GetType().GetFields(AccessTools.all).Where(x => !x.IsStatic && !x.IsLiteral)
.Select(x => SerializeField(null, x, value, references));

// serialize reference
Expand All @@ -68,7 +68,7 @@ private static SerializedData SerializeField(string className, FieldInfo field,
}

// have to go through fields
var fields2 = AccessTools.GetDeclaredFields(value.GetType()).Where(x => !x.IsStatic && !x.IsLiteral)
var fields2 = value.GetType().GetFields(AccessTools.all).Where(x => !x.IsStatic && !x.IsLiteral)
.Select(x => SerializeField(null, x, value, references));
return new(className, field.Name, fields2);
}
Expand Down

0 comments on commit bfe3362

Please sign in to comment.