Skip to content

Implement ManagedReferenceBase<T> with [SerializeReference] wrapper and editor support #3

Description

@xprees

Add a new class ManagedReferenceBase (non-breaking additive change) and a serializable wrapper for inlined values using [SerializeReference] to support polymorphic managed references.

Implementation sketch:

  • New file: Runtime/Base/ManagedReferenceBase.cs
    • [Serializable]
    • public class ManagedReference { [SerializeReference] public T value; }
    • public class ManagedReferenceBase : ReferenceBase {
      // Keep existing behavior; add a new public ManagedReference inlinedManaged;
      // add editor support to draw and toggle between inlinedManaged and variable.
      }
  • Editor: add PropertyDrawer/CustomPropertyDrawer that handles ManagedReference wrapper and offers type picker (uses TypeCache or assembly scan to list concrete types assignable to T).
  • CloningTools: extend Clone to handle managed references wrapped in ManagedReference and deep clone lists of [Serializable] types (already present but document caveats).

Testing:

  • Unit tests for cloning lists of [Serializable] classes and structs.
  • Playmode tests for resetting and preserving protectedDontReset flag.

Docs:

  • Update README: add section "Polymorphic and complex managed types" with examples for [SerializeReference], wrapper usage, and migration instructions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions