Namespace: | Sirenix.OdinInspector.Editor |
Assembly: | Sirenix.OdinInspector.Editor |
public class GenericSelector<T> : OdinSelector<T>, ISelectionChangeListener
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.
}
}
public GenericSelector(params T[] collection)
T[] | collection |
public GenericSelector(IEnumerable<T> collection)
System.Collections.Generic.IEnumerable<T> | collection |
public GenericSelector(string title, params T[] collection)
System.String | title | |
T[] | collection |
public GenericSelector(string title, bool supportsMultiSelect, params T[] collection)
System.String | title | |
System.Boolean | supportsMultiSelect | |
T[] | collection |
public GenericSelector(string title, bool supportsMultiSelect, IEnumerable<T> collection)
System.String | title | |
System.Boolean | supportsMultiSelect | |
System.Collections.Generic.IEnumerable<T> | collection |
public GenericSelector(string title, bool supportsMultiSelect, IEnumerable<GenericSelectorItem<T>> collection)
System.String | title | |
System.Boolean | supportsMultiSelect | |
System.Collections.Generic.IEnumerable<GenericSelectorItem<T>> | collection |
public GenericSelector(string title, bool supportsMultiSelect, Func<T, string> getMenuItemName, params T[] collection)
System.String | title | |
System.Boolean | supportsMultiSelect | |
System.Func<T, System.String> | getMenuItemName | |
T[] | collection |
public GenericSelector(string title, bool supportsMultiSelect, Func<T, string> getMenuItemName, IEnumerable<T> collection)
System.String | title | |
System.Boolean | supportsMultiSelect | |
System.Func<T, System.String> | getMenuItemName | |
System.Collections.Generic.IEnumerable<T> | collection |
public GenericSelector(string title, IEnumerable<T> collection)
System.String | title | |
System.Collections.Generic.IEnumerable<T> | collection |
public GenericSelector(string title, IEnumerable<T> collection, bool supportsMultiSelect, Func<T, string> getMenuItemName = null)
System.String | title | |
System.Collections.Generic.IEnumerable<T> | collection | |
System.Boolean | supportsMultiSelect | |
System.Func<T, System.String> | getMenuItemName |
public bool CheckboxToggle { get; set; }
public bool FlattenedTree { get; set; }
public override string Title { get; }
protected override void BuildSelectionTree(OdinMenuTree tree)
OdinMenuTree | tree |
protected override void DrawSelectionTree()
public override IEnumerable<T> GetCurrentSelection()
System.Collections.Generic.IEnumerable<T> |
public override bool IsValidSelection(IEnumerable<T> collection)
System.Collections.Generic.IEnumerable<T> | collection |
System.Boolean |
public override void SetSelection(T selected)
T | selected |
public override void SetSelection(IEnumerable<T> selection)
System.Collections.Generic.IEnumerable<T> | selection |