We currently serialize defaultValue/currentValue/inlinedValue using Unity's standard serializer (public fields / [SerializeField]). That works for primitives and UnityEngine.Object references, but it doesn't support polymorphic managed references, complex nested non-Unity serializable types, or lists of non-Unity-serializable classes reliably.
Request: Add a documentation entry and an enhancement to introduce a new variant or guidance for serializing polymorphic managed reference types and complex classes.
Proposed changes:
-
Documentation: Add a section "Polymorphic and complex managed types" explaining:
- Unity's serializer limitations (no polymorphic managed references without [SerializeReference], JsonUtility limitations, and IL2CPP/AOT caveats).
- When to use [Serializable] vs [SerializeReference] vs ScriptableObject references.
- How CloningTools.Clone behaves with value types, ICloneable, IList, UnityEngine.Object and [Serializable] classes.
- Example migration: switching a field to [SerializeReference] and adding a custom drawer to choose concrete types.
-
Code enhancement (optional): Add ManagedReferenceBase or a protected switch in ReferenceBase that allows using [SerializeReference] for the inlined/default/current values to support polymorphic types.
- Implement a new serializable wrapper for managed references using [SerializeReference] and provide a PropertyDrawer to pick concrete types in the inspector.
- Ensure CloningTools can deep clone lists and nested [Serializable] classes, or gracefully handle fallback to reference if not serializable.
Benefits:
- Support for interfaces/abstract base classes and polymorphic lists.
- Clear documentation to avoid silent data loss when using non-Unity-serializable types.
Notes:
- This is a non-breaking, additive change. Default behavior remains unchanged for existing primitive and UnityEngine.Object use cases.
We currently serialize defaultValue/currentValue/inlinedValue using Unity's standard serializer (public fields / [SerializeField]). That works for primitives and UnityEngine.Object references, but it doesn't support polymorphic managed references, complex nested non-Unity serializable types, or lists of non-Unity-serializable classes reliably.
Request: Add a documentation entry and an enhancement to introduce a new variant or guidance for serializing polymorphic managed reference types and complex classes.
Proposed changes:
Documentation: Add a section "Polymorphic and complex managed types" explaining:
Code enhancement (optional): Add ManagedReferenceBase or a protected switch in ReferenceBase that allows using [SerializeReference] for the inlined/default/current values to support polymorphic types.
Benefits:
Notes: