Issue #436 new
William Besnard
created an issue

Hi!

I ran into a serialization bug with Odin (last version) on Unity 2018.2.9f1:

I have a SerializedScriptableObject that contains an object like so:

  public class TextAnimationAsset : SerializedScriptableObject,ITextAnimation
    {
        [NonSerialized,OdinSerialize]
        private ITextAnimation textAnimation;
    }

I have to make it Odin Serialized because it contains a list of abstract elements so that's the only way to serialize it:

 [Serializable]
    public class TextAnimation : ITextAnimation
    {

        [BoxGroup("Sequences"), ListDrawerSettings(ListElementLabelName = "Name")]
        public List<TextAnimOperation> Sequences = new List<TextAnimOperation>(3);
   }

Then one of my "TextAnimOperation" contains a gradient:

  [Serializable]
    public class TextAnimOperationColor : TextAnimOperation
    {
        [NonSerialized,OdinSerialize]
        public Gradient Gradient = new Gradient();
    }

Note that all the other data in that TextAnimOperationColor are properly serialized and that the attribute I put here actually do not change anything (the gradient is not serialized with or without them)

I also get an exception when entering play, but I do not know if it is related:

set_mode is not allowed to be called during serialization, call it from OnEnable instead. Called from ScriptableObject 'TextAnimationAsset'.
See "Script Serialization" page in the Unity Manual for further details.
System.Reflection.PropertyInfo:SetValue(Object, Object, Object[])
Sirenix.Serialization.GradientFormatter:Read(Gradient&, IDataReader) (at F:/Sirenix/OdinSerializer/OdinSerializer/Unity Integration/Formatters/GradientFormatter.cs:65)
Sirenix.Serialization.MinimalBaseFormatter`1:Deserialize(IDataReader) (at F:/Sirenix/OdinSerializer/OdinSerializer/Core/Formatters/MinimalBaseFormatter.cs:64)
Sirenix.Serialization.ComplexTypeSerializer`1:ReadValue(IDataReader) (at F:/Sirenix/OdinSerializer/OdinSerializer/Core/Serializers/ComplexTypeSerializer.cs:334)
System.Object:Dynamic_BFT.TextAnimation.TextAnimOperationColor(TextAnimOperationColor&, String, EntryType, IDataReader)
Sirenix.Serialization.RuntimeEmittedFormatter`1:ReadDataEntry(TextAnimOperationColor&, String, EntryType, IDataReader) (at F:/Sirenix/OdinSerializer/OdinSerializer/Core/Formatters/FormatterEmitter.cs:110)
Sirenix.Serialization.EasyBaseFormatter`1:DeserializeImplementation(TextAnimOperationColor&, IDataReader) (at F:/Sirenix/OdinSerializer/OdinSerializer/Core/Formatters/EasyBaseFormatter.cs:40)
Sirenix.Serialization.BaseFormatter`1:Deserialize(IDataReader) (at F:/Sirenix/OdinSerializer/OdinSerializer/Core/Formatters/BaseFormatter.cs:188)
Sirenix.Serialization.BaseFormatter`1:Sirenix.Serialization.IFormatter.Deserialize(IDataReader) (at F:/Sirenix/OdinSerializer/OdinSerializer/Core/Formatters/BaseFormatter.cs:141)
Sirenix.Serialization.ComplexTypeSerializer`1:ReadValue(IDataReader) (at F:/Sirenix/OdinSerializer/OdinSerializer/Core/Serializers/ComplexTypeSerializer.cs:269)
Sirenix.Serialization.ListFormatter`1:DeserializeImplementation(List`1&, IDataReader) (at F:/Sirenix/OdinSerializer/OdinSerializer/Core/Formatters/ListFormatter.cs:91)
Sirenix.Serialization.BaseFormatter`1:Deserialize(IDataReader) (at F:/Sirenix/OdinSerializer/OdinSerializer/Core/Formatters/BaseFormatter.cs:188)
Sirenix.Serialization.ComplexTypeSerializer`1:ReadValue(IDataReader) (at F:/Sirenix/OdinSerializer/OdinSerializer/Core/Serializers/ComplexTypeSerializer.cs:334)
System.Object:Dynamic_BFT.TextAnimation.TextAnimation(TextAnimation&, String, EntryType, IDataReader)
Sirenix.Serialization.RuntimeEmittedFormatter`1:ReadDataEntry(TextAnimation&, String, EntryType, IDataReader) (at F:/Sirenix/OdinSerializer/OdinSerializer/Core/Formatters/FormatterEmitter.cs:110)
Sirenix.Serialization.EasyBaseFormatter`1:DeserializeImplementation(TextAnimation&, IDataReader) (at F:/Sirenix/OdinSerializer/OdinSerializer/Core/Formatters/EasyBaseFormatter.cs:40)
Sirenix.Serialization.BaseFormatter`1:Deserialize(IDataReader) (at F:/Sirenix/OdinSerializer/OdinSerializer/Core/Formatters/BaseFormatter.cs:188)
Sirenix.Serialization.BaseFormatter`1:Sirenix.Serialization.IFormatter.Deserialize(IDataReader) (at F:/Sirenix/OdinSerializer/OdinSerializer/Core/Formatters/BaseFormatter.cs:141)
Sirenix.Serialization.ComplexTypeSerializer`1:ReadValue(IDataReader) (at F:/Sirenix/OdinSerializer/OdinSerializer/Core/Serializers/ComplexTypeSerializer.cs:269)
Sirenix.Serialization.Serializer`1:ReadValueWeak(IDataReader) (at F:/Sirenix/OdinSerializer/OdinSerializer/Core/Serializers/Serializer.cs:261)
Sirenix.Serialization.UnitySerializationUtility:DeserializeUnityObject(Object, IDataReader) (at F:/Sirenix/OdinSerializer/OdinSerializer/Unity Integration/UnitySerializationUtility.cs:1572)
Sirenix.Serialization.UnitySerializationUtility:DeserializeUnityObject(Object, SerializationData&, DeserializationContext, Boolean, List`1) (at F:/Sirenix/OdinSerializer/OdinSerializer/Unity Integration/UnitySerializationUtility.cs:1376)
Sirenix.Serialization.UnitySerializationUtility:DeserializeUnityObject(Object, SerializationData&, DeserializationContext) (at F:/Sirenix/OdinSerializer/OdinSerializer/Unity Integration/UnitySerializationUtility.cs:1112)
Sirenix.OdinInspector.SerializedScriptableObject:UnityEngine.ISerializationCallbackReceiver.OnAfterDeserialize() (at F:/Sirenix/OdinSerializer/OdinSerializer/Unity Integration/SerializedUnityObjects/SerializedScriptableObject.cs:34)

UnityException: set_mode is not allowed to be called during serialization, call it from OnEnable instead. Called from ScriptableObject 'TextAnimationAsset'.
See "Script Serialization" page in the Unity Manual for further details.
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <f2e6809acb14476a81f399aeb800f8f2>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <f2e6809acb14476a81f399aeb800f8f2>:0)
System.Reflection.MonoProperty.SetValue (System.Object obj, System.Object value, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] index, System.Globalization.CultureInfo culture) (at <f2e6809acb14476a81f399aeb800f8f2>:0)
System.Reflection.PropertyInfo.SetValue (System.Object obj, System.Object value, System.Object[] index) (at <f2e6809acb14476a81f399aeb800f8f2>:0)
Sirenix.Serialization.GradientFormatter.Read (UnityEngine.Gradient& value, Sirenix.Serialization.IDataReader reader) (at F:/Sirenix/OdinSerializer/OdinSerializer/Unity Integration/Formatters/GradientFormatter.cs:65)
Sirenix.Serialization.MinimalBaseFormatter`1[T].Deserialize (Sirenix.Serialization.IDataReader reader) (at F:/Sirenix/OdinSerializer/OdinSerializer/Core/Formatters/MinimalBaseFormatter.cs:64)
Sirenix.Serialization.ComplexTypeSerializer`1[T].ReadValue (Sirenix.Serialization.IDataReader reader) (at F:/Sirenix/OdinSerializer/OdinSerializer/Core/Serializers/ComplexTypeSerializer.cs:334)
UnityEngine.Debug:LogException(Exception)
Sirenix.Serialization.CustomLogger:LogException(Exception) (at F:/Sirenix/Sirenix Solution/Sirenix.Serialization.Config/CustomLogger.cs:61)
Sirenix.Serialization.DebugContext:LogException(Exception) (at F:/Sirenix/OdinSerializer/OdinSerializer/Core/Misc/SerializationConfig.cs:237)
Sirenix.Serialization.ComplexTypeSerializer`1:ReadValue(IDataReader) (at F:/Sirenix/OdinSerializer/OdinSerializer/Core/Serializers/ComplexTypeSerializer.cs:357)
System.Object:Dynamic_BFT.TextAnimation.TextAnimOperationColor(TextAnimOperationColor&, String, EntryType, IDataReader)
Sirenix.Serialization.RuntimeEmittedFormatter`1:ReadDataEntry(TextAnimOperationColor&, String, EntryType, IDataReader) (at F:/Sirenix/OdinSerializer/OdinSerializer/Core/Formatters/FormatterEmitter.cs:110)
Sirenix.Serialization.EasyBaseFormatter`1:DeserializeImplementation(TextAnimOperationColor&, IDataReader) (at F:/Sirenix/OdinSerializer/OdinSerializer/Core/Formatters/EasyBaseFormatter.cs:40)
Sirenix.Serialization.BaseFormatter`1:Deserialize(IDataReader) (at F:/Sirenix/OdinSerializer/OdinSerializer/Core/Formatters/BaseFormatter.cs:188)
Sirenix.Serialization.BaseFormatter`1:Sirenix.Serialization.IFormatter.Deserialize(IDataReader) (at F:/Sirenix/OdinSerializer/OdinSerializer/Core/Formatters/BaseFormatter.cs:141)
Sirenix.Serialization.ComplexTypeSerializer`1:ReadValue(IDataReader) (at F:/Sirenix/OdinSerializer/OdinSerializer/Core/Serializers/ComplexTypeSerializer.cs:269)
Sirenix.Serialization.ListFormatter`1:DeserializeImplementation(List`1&, IDataReader) (at F:/Sirenix/OdinSerializer/OdinSerializer/Core/Formatters/ListFormatter.cs:91)
Sirenix.Serialization.BaseFormatter`1:Deserialize(IDataReader) (at F:/Sirenix/OdinSerializer/OdinSerializer/Core/Formatters/BaseFormatter.cs:188)
Sirenix.Serialization.ComplexTypeSerializer`1:ReadValue(IDataReader) (at F:/Sirenix/OdinSerializer/OdinSerializer/Core/Serializers/ComplexTypeSerializer.cs:334)
System.Object:Dynamic_BFT.TextAnimation.TextAnimation(TextAnimation&, String, EntryType, IDataReader)
Sirenix.Serialization.RuntimeEmittedFormatter`1:ReadDataEntry(TextAnimation&, String, EntryType, IDataReader) (at F:/Sirenix/OdinSerializer/OdinSerializer/Core/Formatters/FormatterEmitter.cs:110)
Sirenix.Serialization.EasyBaseFormatter`1:DeserializeImplementation(TextAnimation&, IDataReader) (at F:/Sirenix/OdinSerializer/OdinSerializer/Core/Formatters/EasyBaseFormatter.cs:40)
Sirenix.Serialization.BaseFormatter`1:Deserialize(IDataReader) (at F:/Sirenix/OdinSerializer/OdinSerializer/Core/Formatters/BaseFormatter.cs:188)
Sirenix.Serialization.BaseFormatter`1:Sirenix.Serialization.IFormatter.Deserialize(IDataReader) (at F:/Sirenix/OdinSerializer/OdinSerializer/Core/Formatters/BaseFormatter.cs:141)
Sirenix.Serialization.ComplexTypeSerializer`1:ReadValue(IDataReader) (at F:/Sirenix/OdinSerializer/OdinSerializer/Core/Serializers/ComplexTypeSerializer.cs:269)
Sirenix.Serialization.Serializer`1:ReadValueWeak(IDataReader) (at F:/Sirenix/OdinSerializer/OdinSerializer/Core/Serializers/Serializer.cs:261)
Sirenix.Serialization.UnitySerializationUtility:DeserializeUnityObject(Object, IDataReader) (at F:/Sirenix/OdinSerializer/OdinSerializer/Unity Integration/UnitySerializationUtility.cs:1572)
Sirenix.Serialization.UnitySerializationUtility:DeserializeUnityObject(Object, SerializationData&, DeserializationContext, Boolean, List`1) (at F:/Sirenix/OdinSerializer/OdinSerializer/Unity Integration/UnitySerializationUtility.cs:1376)
Sirenix.Serialization.UnitySerializationUtility:DeserializeUnityObject(Object, SerializationData&, DeserializationContext) (at F:/Sirenix/OdinSerializer/OdinSerializer/Unity Integration/UnitySerializationUtility.cs:1112)
Sirenix.OdinInspector.SerializedScriptableObject:UnityEngine.ISerializationCallbackReceiver.OnAfterDeserialize() (at F:/Sirenix/OdinSerializer/OdinSerializer/Unity Integration/SerializedUnityObjects/SerializedScriptableObject.cs:34)

Comments (0)

  1. Log in to comment