TeamSirenix / odin-serializer

Fast, robust, powerful and extendible .NET serializer built for Unity
http://www.odininspector.com
Apache License 2.0
1.69k stars 193 forks source link

BaseFormatter's "T inherits from UnityEngine.Object" warning doesn't halt serialization properly #63

Open tconkling opened 7 months ago

tconkling commented 7 months ago

I'm serializing data, and I have set DebugContext.ErrorHandlingPolicy = ErrorHandlingPolicy.ThrowOnWarningsAndErrors.

If my game tries to serialize a UnityEngine.Object subclass, I expect that this warning will result in a serialization error and serialization will halt, but that's not the case.

Is there a way to safely halt serialization of Unity objects?

(I've also tried throwing an Exception from a custom IExternalStringReferenceResolver, when encountering a Unity object that's not in the AssetDatabase, but this seems to result in corruption of data - I get "Sirenix.Serialization.SerializationAbortException : The following error was logged during serialization or deserialization: Reached end of array after 0 elements, when 1 elements were expected." errors when deserializing other unrelated data)