Skip to content

Add [SerializeReferenceSelector] dropdown and missing-type repair#49

Draft
VPDPersonal wants to merge 18 commits into
mainfrom
feature/serialize-reference-dropdown
Draft

Add [SerializeReferenceSelector] dropdown and missing-type repair#49
VPDPersonal wants to merge 18 commits into
mainfrom
feature/serialize-reference-dropdown

Conversation

@VPDPersonal

@VPDPersonal VPDPersonal commented Jun 7, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add [SerializeReferenceSelector] — IMGUI and UIToolkit drawers rendering a hierarchical type-picker dropdown for [SerializeReference] fields, with inline resolution of open generic arguments (including nested generics) via GenericTypeResolver.
  • Detect missing managed-reference types straight from the asset YAML and repair them in place: a compact warning notice with an inline Fix picker re-points the stored type while keeping its data — for saved assets and Prefab Mode, at any nesting depth (nested references and [Serializable] containers). Aliased references get a matching Make unique action.
  • Add a Repair Missing References window (Tools → Aspid 🐍) in the Welcome design (dots canvas, asset card, hero states, amber result rows) that scans the whole asset file and fixes every orphaned reference — at any depth, on any child object — through an embedded accordion type picker.
  • Ship a SerializeReferences sample (weapons/effects, a generic Modifier<T> hierarchy, broken/shared-reference demo prefabs) and document the feature in the READMEs (EN/RU, root + Documentation) and the CHANGELOG.

Notes for review

  • New editor code lives under Unity/Editor/Scripts/SerializeReferences/ (drawers, SerializeReferenceField, SerializeReferenceYamlEditor, the repair window) and Types/Selectors/ — the selector now lives in a reusable TypeSelectorView, with TypeSelectorWindow reduced to a thin dropdown host (public Show API unchanged).
  • Trickiest spots: generic-argument resolution (TypeSelectorView + GenericTypeResolver), YAML-based missing-type detection/rewrite (SerializeReferenceYamlEditor), and the repair window's declared-field constraint map.
  • Selector USS was migrated to BEM (aspid-fasttools-type-selector block) and the stylesheet renamed to Aspid-FastTools-TypeSelector.uss (meta GUID preserved).

… drawer

Add a hierarchical type-selector dropdown for [SerializeReference] fields
(single, array and List<T>), reusing TypeSelectorWindow. Picking a concrete
type instantiates it, <None> clears the reference, the assigned instance's
nested properties are drawn inline under a foldout, and an unresolved stored
type is surfaced as a missing-type warning. Implemented for both IMGUI and
UIToolkit inspectors.

TypeSelectorWindow.Show gains an optional candidate-type filter (backward
compatible) used to exclude UnityEngine.Object, open generics, strings and
delegates.
Add a loadout-system sample exercising [SerializeReferenceSelector]: single
IWeapon field, List<IWeapon>, abstract StatusEffect base, and a nested
[SerializeReference] inside Railgun. Includes an IMGUILoadout + forcing editor
to demonstrate the IMGUI path, EN/RU README, and a package.json sample entry.
Add Loadout.prefab (UIToolkit) and IMGUILoadout.prefab (IMGUI) with pre-filled
managed references — single (Railgun + nested BurnEffect), List<IWeapon>
([Pistol, Shotgun]) and abstract-base (FreezeEffect / BurnEffect) — so the
sample can be inspected without building it by hand. Update the EN/RU sample
README "How to run" to drive the prefabs.
- Offer open generic definitions (e.g. Modifier<T>) as candidates: infer
  arguments from a closed-generic field, or resolve them in a new
  recursive, constraint-aware GenericArgumentSelectorWindow, validating
  the closed type against the field before assignment. Works in IMGUI and UIToolkit.
- Add an optional additionalTypes pass-through to TypeSelectorWindow /
  HierarchyBuilder / TypeInfo, and render generic names as Modifier<T>.
- Add a non-abstract Modifier<T> hierarchy (IModifier) with closed-generic
  subclasses, plus IModifier / Modifier<float> / List<IModifier> fields on
  Loadout and IMGUILoadout to exercise open-generic selection and the T picker.
- Document the generic flow in the sample README (EN/RU).
- Note open-generic support and the new additionalTypes parameter in the
  CHANGELOG, and add a generic bullet to the feature section of all four READMEs.
…he dropdown

- Resolve open generics inside TypeSelectorWindow as in-window argument pages (hierarchy, search, breadcrumb, live preview), removing the separate GenericArgumentSelectorWindow and its focus issues
- Extract generic resolution into GenericTypeResolver and add an argumentFilter parameter to TypeSelectorWindow.Show; the flow stays dormant unless open generics are present
- Format generic type names recursively so nested closed generics render fully (Modifier<Modifier<Int32>>)
- Resolve the generic type definition when locating a script so Open Script works for closed generics
@VPDPersonal VPDPersonal added type: feature New feature or capability status: work-in-progress Draft / not ready for review area: runtime Runtime / player code area: editor Editor-only code area: samples Sample projects labels Jun 7, 2026
VPDPersonal and others added 10 commits June 7, 2026 21:07
…eric argument selector

Open generic definitions reach the selector through the additionalTypes
path, which bypasses the name and CompilerGeneratedAttribute checks
applied to ordinary candidates. As a result anonymous types and closure
display classes (e.g. <>c__11<T>, <>f__AnonymousType0<...>) showed up as
argument candidates and bloated the unconstrained (object) list.

Exclude compiler-generated types in IsAssignableGenericDefinition so the
single gate for generic definitions filters them out.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Carry the foldout caption on the toggle's aligned BaseField label so the
  type dropdown starts at the inspector value column, matching SerializableType
- Centre the header row so the open-script button lines up with the dropdown
- Split the dropdown into field/input nodes and cancel the EnumField caption's
  -2px left margin so the text indents like SerializableType
…/paste

- CreateInstancePreservingData carries matching [SerializeField] data across a
  type switch via JsonUtility ToJson/FromJsonOverwrite, instead of resetting
- SerializeReferenceClipboard backs a header right-click Copy/Paste menu scoped
  to the field (IMGUI ContextClick + UIToolkit ContextualMenuManipulator); paste
  builds an independent instance and is disabled when the type is not assignable
… references

- Add an Edit Type action to the missing-type warning: it opens an
  Assembly/Namespace/Class editor and rewrites the stored managed-reference
  type straight into the asset YAML (parser-free, no external deps), since
  Unity cannot reassign a missing reference through the serialization API.
  Applies to ScriptableObjects — the only assets where Unity preserves missing
  references (UUM-129100).
- Detect an aliased managed reference (two fields sharing one instance) and
  offer a Make Unique Reference action that clones it into an independent copy.
- Sample: add a WeaponPreset ScriptableObject with a pre-broken asset, plus
  shared-reference and missing-type demo prefabs, and document how to test both.
…YAML

- Replace the manual Edit-Type window with a Fix button that opens the existing
  hierarchical type picker; the chosen type is rewritten into the asset YAML.
- Read the missing type straight from the asset file (stored id + RefIds type)
  instead of Unity's serialization API, which reports nothing per-property and
  drops the reference on prefabs/GameObjects (UUM-129100). Repair now works on
  prefab assets too, not just ScriptableObjects.
- Detect strictly per-field by resolving the recorded type, removing the
  single-missing fallback that falsely flagged legitimately-empty fields.
- Scan a prefab/ScriptableObject's YAML for every orphaned managed reference —
  at any nesting depth and on any child object — by walking each document's flat
  RefIds block and flagging entries whose stored type no longer resolves.
- List each with its own Fix picker that rewrites the type in the file and
  reimports, reaching references the per-field drawer cannot (nested values,
  child-object components, anything Unity dropped to <None>) without Prefab Mode.
- Open via Tools → Aspid FastTools → Repair Missing References (auto-targets the
  current selection).
… Mode repair

Replace the bulky missing-type and shared-reference help boxes with a
compact yellow inline notice: a small warning icon, terse text and an
underlined, clickable action word (Fix / Make unique) with the full
detail on hover. Covers both the IMGUI and UIToolkit drawers.

Extend missing-type repair to objects open in Prefab Mode: detection
resolves the backing document through the prefab stage (matching the
asset's file id), and the fix is applied in memory — reassigning the
reference and recovering the orphaned field data — because rewriting the
open stage's file would be discarded on save. Saved assets keep the
YAML-rewrite path.

Reselect the inspected objects after a repair so Unity's cached
object-level missing-types banner clears, and guard the UIToolkit field
against the live SerializedObject being invalidated by a reimport.
…n containers

Generalise the YAML reference resolver behind the inline missing-type Fix to
walk a property path of any shape: through managed-reference chains and through
plain [Serializable] containers (struct/class fields and List<T> of them), so a
missing type buried in a slot or list element is detected and repaired inline
like a top-level field.

When an in-memory (Prefab Mode) repair replaces a missing reference that itself
carried missing nested references, clear those now-orphaned entries too so the
object's missing-types banner clears.

Add the SlottedLoadout sample demonstrating [SerializeReferenceSelector]
references inside a container field and a List<T> of containers.
- Redesign the Repair References window in the Welcome style: boxed
  asset card with an Aspid header, centred info/success hero states,
  warning-accented results header and amber gradient rows.
- Extract the hierarchical type selector from TypeSelectorWindow into a
  reusable TypeSelectorView; the window stays a thin dropdown host with
  an unchanged public Show API.
- Expand the selector inline as an accordion under the clicked Fix row
  (dark Aspid panel, one at a time, Escape collapses) instead of the
  floating grey dropdown.
- Migrate selector USS classes to BEM under the
  aspid-fasttools-type-selector block and rename the stylesheet to
  Aspid-FastTools-TypeSelector.uss; sync the asset field when Open()
  retargets an already-open window.
- The repair window moved to Tools → Aspid 🐍 → Repair Missing
  References FastTools; mirror the new path in the CHANGELOG, both
  root/Documentation README pairs and the sample READMEs.
@VPDPersonal VPDPersonal changed the title Add [SerializeReferenceSelector] dropdown for SerializeReference fields Add [SerializeReferenceSelector] dropdown and missing-type repair Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: editor Editor-only code area: runtime Runtime / player code area: samples Sample projects status: work-in-progress Draft / not ready for review type: feature New feature or capability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant