GenericSelector<T>

In simple one-off use cases, making a custom OdinSelector might not be needed, as the GenericSelecor can be populated with anything and customized a great deal.

namespace Sirenix.OdinInspector.Editor
{
public class GenericSelector<T> : OdinSelector<T>
}

Requirements

Namespace: Sirenix.OdinInspector.Editor
Assembly: Sirenix.OdinInspector
Version: 1.0.6.1

See Also

Constructors

Definition Description
GenericSelector(IEnumerable<T>) Initializes a new instance of the GenericSelector<T> class.
GenericSelector(string, bool, Func<T, string>, IEnumerable<T>) Initializes a new instance of the GenericSelector<T> class.
GenericSelector(string, bool, Func<T, string>, T[]) Initializes a new instance of the GenericSelector<T> class.
GenericSelector(string, bool, IEnumerable<T>) Initializes a new instance of the GenericSelector<T> class.
GenericSelector(string, bool, T[]) Initializes a new instance of the GenericSelector<T> class.
GenericSelector(string, IEnumerable<T>) Initializes a new instance of the GenericSelector<T> class.
GenericSelector(string, IEnumerable<T>, bool, Func<T, string>) Initializes a new instance of the GenericSelector<T> class.
GenericSelector(string, T[]) Initializes a new instance of the GenericSelector<T> class.
GenericSelector(T[]) Initializes a new instance of the GenericSelector<T> class.

Properties

Return Type Definition Description
string Title Gets the title. No title will be drawn if the string is null or empty.

Methods

Return Type Definition Description
void BuildSelectionTree(OdinMenuTree) Builds the selection tree.

Example

SomeType someValue;

[OnInspectorGUI]
void OnInspectorGUI()
{
    if (GUILayout.Button("Open Generic Selector Popup"))
    {
        List<SomeType> source = ...;
        GenericSelector<SomeType> selector = new GenericSelector<SomeType>("Title", false, x => x.Path, source);
        selector.SetSelection(this.someValue);
        selector.SelectionTree.Config.DrawSearchToolbar = false;
        selector.SelectionTree.DefaultMenuStyle.Height = 22;
        selector.SelectionConfirmed += selection => this.someValue = selection.FirstOrDefault()
        var window = selector.ShowInPopup();
        window.OnEndGUI += () => { EditorGUILayout.HelpBox("A quick way of injecting custom GUI to the editor window popup instance.", MessageType.Info); };
        window.OnClose += selector.SelectionTree.Selection.ConfirmSelection; // Confirm selection when window clses.
    }
}