@@ -282,6 +282,8 @@ ICustomizableEnumSerializer ICustomizableEnumSerializer.GetCopyAs( EnumSerializa
282282 internal abstract class UnityEnumMessagePackSerializer : NonGenericMessagePackSerializer , ICustomizableEnumSerializer
283283 {
284284 private readonly Type _underlyingType ;
285+ private readonly Dictionary < object , string > _serializationMapping ;
286+ private readonly Dictionary < string , object > _deserializationMapping ;
285287 private EnumSerializationMethod _serializationMethod ; // not readonly -- changed in cloned instance in GetCopyAs()
286288
287289 protected UnityEnumMessagePackSerializer ( SerializationContext ownerContext , Type targetType , EnumSerializationMethod serializationMethod )
@@ -296,9 +298,9 @@ protected UnityEnumMessagePackSerializer( SerializationContext ownerContext, Typ
296298
297299 this . _serializationMethod = serializationMethod ;
298300 this . _underlyingType = Enum . GetUnderlyingType ( targetType ) ;
299- var members = Enum . GetValues ( typeof ( TEnum ) ) as TEnum [ ] ;
300- this . _serializationMapping = new Dictionary < TEnum , string > ( members . Length ) ;
301- this . _deserializationMapping = new Dictionary < string , TEnum > ( members . Length ) ;
301+ var members = Enum . GetValues ( targetType ) as object [ ] ;
302+ this . _serializationMapping = new Dictionary < object , string > ( members . Length ) ;
303+ this . _deserializationMapping = new Dictionary < string , object > ( members . Length ) ;
302304 foreach ( var member in members )
303305 {
304306 var asString = ownerContext . EnumSerializationOptions . SafeNameTransformer ( member . ToString ( ) ) ;
@@ -336,7 +338,7 @@ protected internal sealed override object UnpackFromCore( Unpacker unpacker )
336338 {
337339 var asString = unpacker . LastReadData . AsString ( ) ;
338340
339- TEnum result ;
341+ object result ;
340342 if ( ! this . _deserializationMapping . TryGetValue ( asString , out result ) )
341343 {
342344 // May be undefined value which should be numeric, or PacakCasing.
0 commit comments