diff --git a/Il2CppInspector.Common/Outputs/CSharpCodeStubs.cs b/Il2CppInspector.Common/Outputs/CSharpCodeStubs.cs index 182de6b..7c55bad 100644 --- a/Il2CppInspector.Common/Outputs/CSharpCodeStubs.cs +++ b/Il2CppInspector.Common/Outputs/CSharpCodeStubs.cs @@ -390,7 +390,7 @@ namespace Il2CppInspector.Outputs else sb.Append($"{field.FieldType.GetScopedCSharpName(scope)} {field.CSharpSafeName}"); if (field.HasDefaultValue) - sb.Append($" = {field.DefaultValueString}"); + sb.Append($" = {field.GetDefaultValueString(scope)}"); sb.Append(";"); // Don't output field indices for const fields (they don't have any storage) // or open generic types (they aren't known until runtime) diff --git a/Il2CppInspector.Common/Reflection/FieldInfo.cs b/Il2CppInspector.Common/Reflection/FieldInfo.cs index 3d06f17..56718d2 100644 --- a/Il2CppInspector.Common/Reflection/FieldInfo.cs +++ b/Il2CppInspector.Common/Reflection/FieldInfo.cs @@ -34,7 +34,7 @@ namespace Il2CppInspector.Reflection { public bool HasDefaultValue => (Attributes & FieldAttributes.HasDefault) != 0; public object DefaultValue { get; } - public string DefaultValueString => HasDefaultValue ? DefaultValue.ToCSharpValue(FieldType) : ""; + public string GetDefaultValueString(Scope usingScope = null) => HasDefaultValue ? DefaultValue.ToCSharpValue(FieldType, usingScope) : ""; // Information/flags about the field public FieldAttributes Attributes { get; }