Namespace: | Sirenix.OdinInspector.Editor |
Assembly: | Sirenix.OdinInspector.Editor |
public class TypeSelector : OdinSelector<Type>
Type[] selectedTypes;
void OnGUI()
{
// Use the selector manually. See the documentation for OdinSelector for more information.
if (GUILayout.Button("Open My Selector"))
{
TypeSelector selector = new TypeSelector(customListOfTypes);
TypeSelector selector = new TypeSelector(AssemblyTypeFlags.CustomTypes, supportsMultiSelect: true);
selector.SetSelection(this.selectedTypes);
selector.SelectionConfirmed += selection => this.selectedTypes = selection.ToArray();
selector.ShowInPopup(); // Returns the Odin Editor Window instance, in case you want to mess around with that as well.
}
}
private static Type currentSelectedType;
private static IEnumerable<Type> currentSource;
private static Func<Rect, OdinSelector<Type>> createTypeSelector = (rect) =>
{
TypeSelector selector = new TypeSelector(currentSource, false);
selector.SetSelection(currentSelectedType);
selector.ShowInPopup(rect);
return selector;
};
public static Type DrawTypeSelectorDropdown(GUIContent label, Type selectedType, IEnumerable<Type> source)
{
currentSource = source;
currentSelectedType = selectedType;
var dropdownText = selectedType == null ? "None" : selectedType.GetNiceName();
var selected = TypeSelector.DrawSelectorDropdown(label, dropdownText, createTypeSelector);
if (selected != null && selected.Any())
{
selectedType = selected.FirstOrDefault();
}
return selectedType;
}
public TypeSelector(AssemblyTypeFlags assemblyFlags, bool supportsMultiSelect)
AssemblyTypeFlags | assemblyFlags | |
System.Boolean | supportsMultiSelect |
public TypeSelector(IEnumerable<Type> types, bool supportsMultiSelect)
System.Collections.Generic.IEnumerable<System.Type> | types | |
System.Boolean | supportsMultiSelect |
public bool FlattenTree
public bool HideNamespaces
public override string Title { get; }
protected override void BuildSelectionTree(OdinMenuTree tree)
OdinMenuTree | tree |
protected override float DefaultWindowWidth()
System.Single |
public override bool IsValidSelection(IEnumerable<Type> collection)
System.Collections.Generic.IEnumerable<System.Type> | collection |
System.Boolean |
public override void SetSelection(Type selected)
System.Type | selected |