Skip to content

Latest commit

 

History

History
60 lines (46 loc) · 3 KB

File metadata and controls

60 lines (46 loc) · 3 KB

SerializeReference Dropdown

[ReferenceDropdown]

Decorates a [SerializeReference] field, adding a type selection dropdown and other optional features.

Argument Description
type (optional) Type constraint
features (optional) Feature selection flags:
- Remove the constrained type label (Type)
- Remove "Set to null" from the context menu
- Hide the warning icon for null entries
[SerializeReference, ReferenceDropdown]
public Fruit[] FruitInstance;

ReferenceDropdown Example

ReferenceDropdown supports property drawers, decorators, and UIToolkit.

  • IMGUI support (optional) uses IL injection to make multiple modifications to the editor DLL.
  • UIToolkit support uses stateful DecoratorDrawer hacks.

Other implementations often don't support property drawers due to this complexity.

Installation

Warning
This package requires Unity 2020.3+
In versions below 2021 ReferenceDropdown may draw incorrectly when used with property drawers that nest property fields.

UIToolkit support may have some issues responding to changes, especially involving Undo.
If you have a problem, feel free to create an issue ticket, but pull requests are preferred as this is just a painfully buggy and unsupported area of Unity.

openupm

Add the OpenUPM registry

  1. Open Edit/Project Settings/Package Manager
  2. Add a new Scoped Registry (or edit the existing OpenUPM entry):
    Name: OpenUPM
    URL:  https://package.openupm.com/
    Scope(s): com.vertx
              com.needle
    
  3. Save

Add the package

  1. Open the Package Manager via Window/Package Manager.
  2. Select the + from the top left of the window.
  3. Select Add package by Name or Add package from Git URL.
  4. Enter com.vertx.serializereference-dropdown.
  5. Select Add.

Optionally add IMGUI support

Add com.needle.editorpatching. The com.needle scope is only required to support IMGUI.
The implementation relies on patching the editor DLL so avoid adding it if it's not required.

ko-fi