Class InspectorFieldContainer

The InspectorFieldContainer class provider help functions to create field registrations for an inspector.

To create an inspector that can be easily placed into a UILayout it's recommended to use UIObjectInspector instead.

Constructors

Properties

actions: InspectorAction[]

List of actions created and updated by the _inspector.

Context of the object we're inspecting, if provided.

List of fields created and updated by the _inspector.

formLayout: UIFormLayout

The field container.

inspectorParentProperty: InspectableProperty

An InspectorProperty that represents a parent of the inspector. Can be null.

isLazyRefreshing: boolean

If set to true, the field _inspector will perform lazy refreshing and will only trigger the refresh methods of it's attached fields if notifyNeedsRefresh is called.

needsRefresh: boolean

A flag that indicates if the inspector field _inspector needs to be refreshed since the last call to refresh.

parentWeak: WeakRef<InspectorFieldContainer>

The parent layout. Only available for types such as InlineObjectInspectorField.

persistLabelWidths = false

Determines if label widths are persisted in the LocalOnlyEditorSettings.

Accessors

  • get isResizeable(): boolean
  • Determines if the user is allowed to resize the inspector or if the label is at a fixed position.

    Returns boolean

  • set isResizeable(value): void
  • Parameters

    • value: boolean

    Returns void

  • get maximumDeducedLabelWidth(): number
  • The maximum label width as a percentage of the whole element width. Used only when deducing a label width.

    Returns number

  • set maximumDeducedLabelWidth(value): void
  • Parameters

    • value: number

    Returns void

Methods

  • Adds a custom action which will invoke the given callback function when clicked by the user.

    Parameters

    • name: string

      Name of the field.

    • onTriggered: (() => void)

      Callback invoked when the action is triggered.

        • (): void
        • Returns void

    • Optionalstyle: InspectableActionStyle | Partial<InspectableActionStyle>

      Contains various styling parameters to be used with the action like value tooltip or category.

    Returns void

  • Creates a new action acting on the provided method.

    Type Parameters

    • T extends object

    Parameters

    • name: string

      Unique name representing the action field.

    • title: string

      Title to display on the action as.

    • action: InspectableAction<T>

      Method used to access trigger the action when clicked.

    Returns void

  • Adds a condition that determines whether a field will be shown or hidden.

    Parameters

    • field: string

      Name of the field the condition applies to.

    • callback: (() => boolean)

      The callback that returns true if the field should be shown, false otherwise.

        • (): boolean
        • Returns boolean

    • Optionaltype: EnumValue<InspectorFieldConditionalType, number>

      Which InspectorField member should be controlled by the new Conditional.

    Returns void

  • Adds a custom inspectable field with a custom getter and setter.

    Type Parameters

    • T

    Parameters

    • type: ClassOf<T>

      The field type being inspected.

    • name: string | I18N

      Name of the field.

    • getter: (() => ValueTypeOf<T>)

      Method that returns the current value of the field.

    • setter: ((value: ValueTypeOf<T>) => void)

      Method that sets a new value of the field.

    • Optionalinline: boolean

      If true, will inline the field parameters identical to the InlineAttribute.

    • OptionalfnOverrideCallback: InspectorOverrideCallback

      Optional callback allowing the caller to override how is the field created.

    Returns InspectorFieldBase

    A reference to the added inspector field object.

  • Creates the default inspector UI for the provided object.

    Type Parameters

    • T extends object = any

    Parameters

    • instance: T

      Object whose fields to create the UI for.

    • OptionalfilterType: Type

      If not null, the added fields will be limited to this particular type (not including any base types the actual object type might be a part of). If null, then fields for the entire class hierarchy of the provided object's type will be created.

    • OptionalfnOverrideCallback: InspectableObjectFieldCallback<T>

      Optional callback that allows you to override the look of individual fields in the object. If non-null the callback will be called with information about every field in the provided object. If the callback returns non-null that inspectable field will be used for drawing the UI, otherwise the default inspector field type will be used.

    • OptionalfnOnFilterField: InspectableObjectFieldFilterCallback<T>

      Optional callback that allows you to filter fields in the object. If non-null the callback will be called with information about every field in the provided object. If the callback returns false, the field will not be added to the inspector.

    Returns InspectableObject<T>

  • Adds a custom inspectable field of the specified name in the inspectableObject.

    Type Parameters

    • T extends object

    Parameters

    Returns InspectorFieldBase

    A reference to the added inspector field object.

  • Adds a custom inspectable field backed by a InspectableProperty.

    Parameters

    • name: string

      Name of the field.

    • property: InspectableProperty

      Property used to access the field contents.

    • OptionalfnOverrideCallback: InspectorOverrideCallback

      Optional callback allowing the caller to override how is the field created.

    Returns InspectorFieldBase

    A reference to the added inspector field object.

  • Adds a UIHorizontalLayout to the field layout.

    Returns UIHorizontalLayout

    The layout.

    If the inspector requires a refresh, the layout must be updated manually. When implementing a ObjectInspectorField or an InlineObjectInspectorField the onRefresh method override can be used to respond to change in the parent field and update the custom layout.

  • Creates the default inspector UI for the provided InspectableObject.

    Type Parameters

    • T extends object

    Parameters

    • inspectableObject: InspectableObject<T>

      Object whose fields to create the UI for.

    • OptionalfilterType: Type

      If specified, the added fields will be limited to this particular type (not including any base types the actual object type might be a part of). If null, then fields for the entire class hierarchy of the provided object's type will be created.

    • OptionalfnOverrideCallback: InspectableObjectFieldCallback<T>

      Optional callback that allows you to override the look of individual fields in the object. If non-null the callback will be called with information about every field in the provided object. If the callback returns non-null that inspectable field will be used for drawing the UI, otherwise the default inspector field type will be used.

    • OptionalfnOnFilterField: InspectableObjectFieldFilterCallback<T>

      Optional callback that allows you to filter fields in the object. If non-null the callback will be called with information about every field in the provided object. If the callback returns false, the field will not be added to the inspector.

    Returns void

  • Defines a condition that determines whether a category panel is open or closed.

    Parameters

    • name: string

      The category name whose panel is being controlled.

    • callback: (() => boolean)

      The callback that returns true if the category should be open, false otherwise.

        • (): boolean
        • Returns boolean

    • onToggle: ((isToggled: boolean) => void)

      A secondary callback that will be called each time the user has toggled the category panel manually.

        • (isToggled): void
        • Parameters

          • isToggled: boolean

          Returns void

    • Optionaltype: EnumValue<InspectorFieldCategoryConditionalType, number>

      The type of conditional to be added to for the category.

    Returns void

  • Adds a UIVerticalLayout to the field layout.

    Returns UIVerticalLayout

    The layout.

    If the inspector requires a refresh, the layout must be updated manually. When implementing a ObjectInspectorField or an InlineObjectInspectorField the onRefresh method override can be used to respond to change in the parent field and update the custom layout.

  • Opens up a new category. Any new fields will be parented to this category. Category must be closed by calling endCategory or by calling this method with a new category.

    Parameters

    • categoryName: string

      Name of the category.

    • OptionalaccessoryElement: UIElementBase

      An optional UIElementBase to use as foldout accessory. If the category was already constructed the accessory will not be used.

    Returns void

  • Destroys and removes all the child inspector fields.

    Returns void

  • Removes all previously created field conditions.

    Returns void

  • Deduces a suitable width for the inspector labels.

    Returns void

  • Ends the category started with beginCategory.

    Returns void

  • Finds a field by it's path.

    Parameters

    • path: string

      The path of the field to be located.

    Returns InspectorFieldBase

    The field at the given path, if it exists.

  • Changes keyboard focus to the provided field.

    Parameters

    • path: string

      Path to the field on the object being inspected.

    Returns boolean

    true if the field was found and focus was set, false otherwise.

  • Notifies the owning inspector that it needs to be refreshed on the next update loop.

    Returns void

  • Checks if contents of the inspector fields have been modified, and updates them if needed.

    Parameters

    • OptionalisForced: boolean

      Forces the UI fields to display the latest values assigned on the object.

    • OptionalstartingIndex: number

      The index to start refreshing the items. This is mostly useful for inline inspectors.

    Returns EnumValue<InspectableState, number>

    State representing was anything modified between two last calls to refresh.

  • Checks if contents of the inspector fields have been modified, and updates them if needed.

    Parameters

    • flags: EnumValue<InspectableRefreshFlag, number>

      Flags that determine how fields should be refreshed.

    • OptionalstartingIndex: number

      The index to start refreshing the items. This is mostly useful for inline inspectors.

    Returns EnumValue<InspectableState, number>

    State representing was anything modified between two last calls to refreshWithFlags.

  • Opens up a new category by calling beginCategory and calls action. After callback returns, the category is closed by calling endCategory.

    Parameters

    • name: string

      The category name. All fields created inside action will be added to this category.

    • callback: (() => void)

      A callback to be called after the category is created and before it is closed.

        • (): void
        • Returns void

    • OptionalaccessoryElement: UIElementBase

      An optional UIElementBase to use as foldout accessory. If the category was already constructed the accessory will not be used.

    Returns void

  • Gets the last saved value for label widths of the given key.

    Parameters

    • key: string

      The key to fetch the label width value for.

    • Optionaldepth: number

      The depth level to fetch the label width for.

    Returns number

    The label width as a percentage of the whole inspector width.

  • Sets and saves a new value for label widths of the given key.

    Parameters

    • key: string

      The key to set the label width value for.

    • width: number

      The label width as a percentage of the whole inspector width.s

    • Optionaldepth: number

      The depth level to set the label width for.

    Returns void