ScriptableFactorySelector

Generic Odin selector popup that displays all registered factories matching a specific IScriptableFactory<TObject, TData> interface. Used by FactorableSpawnerDrawer to let users pick a factory from a dropdown.

Definition

Namespace: Paragon.Core.ScriptableFactory.Editor Assembly: Paragon.Editor.dll

public class ScriptableFactorySelector<TObject, TData> : OdinSelector<ScriptableFactory>
    where TObject : class, IFactorable<TData>
    where TData : FactorableData

Inherits: OdinSelector<ScriptableFactory> (Sirenix.OdinInspector.Editor) Type Constraints:

  • TObject : class, IFactorable<TData>

  • TData : FactorableData

Remarks

The selector queries ScriptableFactoryRegistry.GetAllFactoriesOfType() at construction time using the resolved IScriptableFactory<TObject, TData> type. Only factories registered in the ScriptableFactoryRegistry are shown.

The popup always includes a "None" option at the top (which invokes the callback with null) followed by all matching factories keyed by their asset name. Single-click selection is enabled — clicking an entry immediately confirms the selection and closes the popup.

Quick Lookup

Goal
How

Create a selector

new ScriptableFactorySelector<TObj, TData>(callback)

Show the popup

selector.Show(buttonRect)

Handle selection

Provide an Action<IScriptableFactory<TObj, TData>> callback

Clear selection

User clicks "None" in the popup

Properties

Title

The popup window title.

Constructor

ScriptableFactorySelector(Action<IScriptableFactory<TObject, TData>>)

Creates a selector with a callback invoked when a factory is selected.

Parameter
Type
Description

factorySelected

Action<IScriptableFactory<TObject, TData>>

Callback invoked with the selected factory (or null for "None")

Methods

BuildSelectionTree

Builds the Odin menu tree with a "None" entry followed by all matching factories from the registry. Enables single-click selection.

Behavior:

  • Subscribes to SelectionConfirmed event

  • Disables the search toolbar

  • Sets menu item height to 20px

  • Adds "None" → null entry

  • Adds each factory keyed by ScriptableFactory.name

Show

Displays the selector as a popup window anchored to the given button rect.

Parameter
Type
Description

buttonRect

Rect

The screen-space rect of the button that triggered the popup

Behavior: Opens a popup window 115px wide. Registers a cleanup handler for when the window closes.

Common Pitfalls

circle-exclamation
circle-exclamation

Examples

Using the Selector in a Custom Drawer

See Also

Last updated