Class ScyllaPresetSelector
A UnityEngine.UIElements.VisualElement that wraps a UnityEngine.UIElements.DropdownField with a
label and exposes a PresetSelected event. Replaces the deleted
IMGUI PresetSelectorWidget.
Implements
Inherited Members
Namespace: Scylla.Core.Editor
Assembly: ScyllaCore.Editor.dll
Syntax
public sealed class ScyllaPresetSelector : VisualElement, IEventHandler, IResolvedStyle, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, ICustomStyle
Remarks
The inner DropdownField fills the available width via
style.flexGrow = 1. Callers can add the element to any flex row and
the dropdown will fill the remaining space after sibling elements.
Use SetSelectedIndexWithoutNotify(int) to programmatically select a preset during initialization without triggering PresetSelected.
Constructors
ScyllaPresetSelector(string, IList<string>, int)
Creates a new preset selector with the given label, preset list, and initial selection. Fires PresetSelected whenever the user changes the dropdown value.
Declaration
public ScyllaPresetSelector(string label, IList<string> presets, int initialIndex = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| string | label | Label text displayed to the left of the dropdown by the UnityEngine.UIElements.DropdownField. Pass an empty string for a label-free control. |
| IList<string> | presets | The list of preset names to populate the dropdown. A defensive copy is made, so mutating the source list after construction has no effect; use SetPresets(IList<string>) to update the choices. |
| int | initialIndex | Zero-based index of the preset selected on construction. Default: 0. |
Properties
SelectedIndex
Gets the zero-based index of the currently selected preset within the current choices list.
Declaration
public int SelectedIndex { get; }
Property Value
| Type | Description |
|---|---|
| int | The selected index, or |
SelectedPreset
Gets the name of the currently selected preset, as shown in the dropdown.
Declaration
public string SelectedPreset { get; }
Property Value
| Type | Description |
|---|---|
| string | The selected preset name, or an empty string when the preset list is empty. |
Methods
SetPresets(IList<string>)
Replaces the list of available presets. A defensive copy is made from
presets. The current selection is cleared if it no longer
exists in the new list.
Declaration
public void SetPresets(IList<string> presets)
Parameters
| Type | Name | Description |
|---|---|---|
| IList<string> | presets | The new list of preset names. Must not be |
SetSelectedIndexWithoutNotify(int)
Programmatically selects the preset at index without raising
PresetSelected. Use this during initialization to restore a saved
selection without side effects.
Declaration
public void SetSelectedIndexWithoutNotify(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | Zero-based index of the preset to select. If out of range the selection is set to an empty string. |
Events
PresetSelected
Raised when the user selects a different preset in the dropdown. The argument is the newly selected preset name. Not fired when the selection is changed programmatically via SetSelectedIndexWithoutNotify(int).
Declaration
public event Action<string> PresetSelected
Event Type
| Type | Description |
|---|---|
| Action<string> |