Add [SerializeReferenceSelector] dropdown and missing-type repair#49
Draft
VPDPersonal wants to merge 18 commits into
Draft
Add [SerializeReferenceSelector] dropdown and missing-type repair#49VPDPersonal wants to merge 18 commits into
VPDPersonal wants to merge 18 commits into
Conversation
… 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
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
[SerializeReferenceSelector]— IMGUI and UIToolkit drawers rendering a hierarchical type-picker dropdown for[SerializeReference]fields, with inline resolution of open generic arguments (including nested generics) viaGenericTypeResolver.[Serializable]containers). Aliased references get a matching Make unique action.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.SerializeReferencessample (weapons/effects, a genericModifier<T>hierarchy, broken/shared-reference demo prefabs) and document the feature in the READMEs (EN/RU, root + Documentation) and the CHANGELOG.Notes for review
Unity/Editor/Scripts/SerializeReferences/(drawers,SerializeReferenceField,SerializeReferenceYamlEditor, the repair window) andTypes/Selectors/— the selector now lives in a reusableTypeSelectorView, withTypeSelectorWindowreduced to a thin dropdown host (publicShowAPI unchanged).TypeSelectorView+GenericTypeResolver), YAML-based missing-type detection/rewrite (SerializeReferenceYamlEditor), and the repair window's declared-field constraint map.aspid-fasttools-type-selectorblock) and the stylesheet renamed toAspid-FastTools-TypeSelector.uss(meta GUID preserved).