Class TypeField
Namespace: Aspid.FastTools.Types.Editors
Assembly: Aspid.FastTools.Editor.dll
BaseField<T> of Type for selecting a type and optionally storing its assembly-qualified name.
[UxmlElement]
public class TypeField : BaseField<Type>, IEventHandler, IResolvedStyle, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, ICustomStyle, IBindable, IMixedValueSupport, INotifyValueChanged<Type>
Inheritance
object ← CallbackEventHandler ← Focusable ← VisualElement ← BindableElement ← AbstractBaseField ← BaseField<Type> ← TypeField
Derived
Implements
IEventHandler, IResolvedStyle, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, ICustomStyle, IBindable, IMixedValueSupport, INotifyValueChanged<Type>
Extension Methods
VisualElementExtensions.AddAspidWindowTheme<TypeField>(TypeField), VisualElementExtensions.AddOpenScriptCommand<TypeField>(TypeField, Object), INotifyValueChangedExtensions.AddValueChanged<TypeField, TValue>(TypeField, EventCallback<ChangeEvent<TValue>>), IBindableExtensions.BindPropertyTo<TypeField>(TypeField, SerializedProperty), IBindableExtensions.BindTo<TypeField>(TypeField, SerializedObject, string), VisualElementExtensions.BindTo<TypeField>(TypeField, SerializedObject), VisualElementExtensions.GetOwnerWindow(VisualElement), ProfilerMarkerExtensionsForGenerator.Marker<TypeField>(TypeField, int), INotifyValueChangedExtensions.RemoveValueChanged<TypeField, TValue>(TypeField, EventCallback<ChangeEvent<TValue>>), IBindableExtensions.SetBindingPath<TypeField>(TypeField, string), BaseFieldExtensions.SetLabel<TypeField, TValue>(TypeField, string), INotifyValueChangedExtensions.SetValue<TypeField, TValue>(TypeField, TValue, bool), VisualElementExtensions.UnbindFrom<TypeField>(TypeField)
Remarks
UXML creates an unbound field: it ignores binding-path, and TypeField.Types and TypeField.Predicate have no UXML attributes. Create a bound or constrained field in C#.
Not designed for inheritance outside the package.
Constructors
TypeField()
Creates an unbound field without a label.
public TypeField()
TypeField(SerializedProperty)
Creates a field bound to property, labeled with its display name.
public TypeField(SerializedProperty property)
Parameters
property SerializedProperty
A string property holding the assembly-qualified type name.
Exceptions
property is null.
property is not a string property, or its path no longer exists on its targets.
TypeField(string, SerializedProperty)
Creates a bound field: the picked type's name is written to the property, and external edits are reflected back into the field.
public TypeField(string label, SerializedProperty property)
Parameters
label string
The field label; null for none.
property SerializedProperty
A string property holding the assembly-qualified type name.
Remarks
Before ChangeEvent<T> is sent, a pick writes the property and calls
Update on the SerializedObject of property:
a change handler reads the picked name from property, and edits it applies through that
object keep the pick. Changes not yet applied to that object are lost.
Exceptions
property is null.
property is not a string property, or its path no longer exists on its targets.
TypeField(string)
Creates an unbound field without an initial type; the picked type is reported only through the change event.
public TypeField(string label)
Parameters
label string
The field label; null for none.
TypeField(string, Type)
Creates an unbound field; the picked type is reported only through the change event.
public TypeField(string label, Type defaultValue)
Parameters
label string
The field label; null for none.
defaultValue Type
The type shown initially, or null for <None>.
Properties
Allow
Gets or sets which kinds of types can be picked.
[UxmlAttribute]
public TypeAllow Allow { get; set; }
Property Value
TypeAllow
Remarks
TypeAllow.None by default, so only concrete types are offered, unlike
TypeSelectorAttribute.Allow, which defaults to TypeAllow.All.
AssemblyQualifiedName
Gets the assembly-qualified name of the selected type, or the stored name of a missing type; an empty string when no type is selected.
public string AssemblyQualifiedName { get; }
Property Value
ExcludeEditorOnlyTypes
Gets or sets a value indicating whether types from editor-only assemblies are left out, for a value that a player build must resolve.
[UxmlAttribute]
public bool ExcludeEditorOnlyTypes { get; set; }
Property Value
Remarks
A bound field turns it on when its property belongs to an object of a runtime assembly.
HideNoneOption
Gets or sets a value indicating whether the <None> row is left out, for a field whose value
must never be cleared.
[UxmlAttribute]
public bool HideNoneOption { get; set; }
Property Value
IsReadOnly
Gets or sets a value indicating whether the dropdown is disabled, so the displayed type cannot be changed.
[UxmlAttribute]
public bool IsReadOnly { get; set; }
Property Value
Remarks
The open-in-script-editor button stays active.
Predicate
Gets or sets the predicate applied to each candidate after the TypeField.Types and
TypeField.Allow checks. null keeps every matching type.
public Func<Type, bool> Predicate { get; set; }
Property Value
Types
Gets or sets the base types; the dropdown lists only types assignable to every one of them.
public Type[] Types { get; set; }
Property Value
Type[]
Remarks
null entries are dropped. For a closed generic type such as IHandler<int>,
the dropdown also offers the generic classes that close to it, such as Handler<int>.
value
Gets or sets the selected type, clearing any unresolved name and notifying listeners when it is cleared.
public override sealed Type value { get; set; }
Property Value
Methods
SetValueFromAssemblyQualifiedNameWithoutNotify(string)
Sets the value from an assembly-qualified type name without raising a change event.
public void SetValueFromAssemblyQualifiedNameWithoutNotify(string assemblyQualifiedName)
Parameters
assemblyQualifiedName string
The type name, or null or whitespace for an empty selection.
Remarks
A name that cannot be resolved is preserved, so the field renders a <Missing> caption
instead of silently clearing.
SetValueWithoutNotify(Type)
Sets the displayed type and clears any unresolved name without raising a change event.
public override sealed void SetValueWithoutNotify(Type newValue)
Parameters
newValue Type
The type to show, or null for an empty selection.
UpdateMixedValueContent()
Called when the mixed-value state changes to refresh the caption and script button.
protected override sealed void UpdateMixedValueContent()