Avoiding Unity's Infinite Depth Warning

By default, Unity doesn't support serializing references, polymorphism, or null values. This means they need to protect themselves against infinite depth serialization loops, where a type contains a value of its own type. They scan for types they might serialize, that contain themselves, and then give you a warning in the console.

Odin, however, does support serializing references, polymorphism, and null values, and Unity's warning can be quite inconvenient to get rid of. We have introduced a work-around to get rid of it, while still telling Odin to serialize the value. It is not pretty, but it is quite simple, and it works.

There is a special case introduced: if a member is marked with both the NonSerialized and OdinSerialize attributes, the member will be serialized by Odin. This means that Unity will pass your self-referential member by, but Odin will still find it and serialize it.