UI input filters are used to show or hide inputs of UI boxes based on conditions.
UI boxes display their inputs (e.g. buttons) as they receive them from control (e.g. a choice dialogue or save game menu). Input filters can be used to only display inputs of the UI box that match certain conditions.
Unity UI #
When using the Unity UI module, input filters are added using game objects and components as part of the UI box’s prefab.
The scene hierarchy context menu offers a quick way to add the individual parts of a UI input filter system.
UI Input Filter Component #
The UI Input Filter component is used for individual input filters. It defines the type of filter and uses other input components to handle the actual control of the filter. Most filter types use a bool input to turn them on or off, e.g. using a UI Toggle Input component for receiving the input and controlling the filter’s state (on or off).
Using the scene hierarchy context menu you can quickly create an input filter setup:
- Makinom > UI Box > Input Filter > Toggle Input Filter (TextMeshPro)
Creates an input filter with a UI Toggle Input. - Makinom > UI Box > Input Filter > Search Input Filter (TextMeshPro)
Creates an input filter with a UI Text Input and a search filter type setup.
Input filters define their input’s content (i.e. text/icon shown by the input and a description) and can optionally define other input filters that should be disabled if the filter is enabled.
Depending on the input filter’s type, other settings might be available, e.g.:
- Single Filter
If enabled, the input filter can only be used alone and all other filters are disabled.
This is automatically happening for the None type filter. - Check Unavailable
The filter checsk if it’s available for the current list of inputs of the UI box.
E.g. a Text or Variable filter checks if any of the inputs will match the conditions, disabling the filter if no match is found.
The following input filter types are available.
None #
Doesn’t filter anything and disables all other filters (i.e. shows all inputs).
Uses a bool value input.
Text Search #
Filters by the input’s main content text using a search field to enter text.
Uses a string value input (e.g. a UI Text Input component).
Text #
Filters by the input’s main content text using a defined text.
Uses a bool value input.
Variable #
Filters by the input’s variables (from input’s schematic context content).
Uses a bool value input.
UI Box Input Filters Component #
The UI Box Input Filters component manages the UI Input Filter components. It’ll automatically find all input filters that are placed on the same game object or it’s child objects. You can optionally also add input filters directly to the component for management, e.g. in case input filters are not placed on child objects of the component’s game object or you want to guarantee their order for controls.
Unavailable input filters can optionally be hidden (i.e. instead of showing them inactive, their game objects are disabled). You can define if all or just one of the filters has to be valid for an input to be displayed by the UI box.
Additionally, this component can override the default input filter controls of the UI box with custom controls. Input filters can be controlled with 3 input keys, to select the next or previous filter and to enable/disable it.
Using the scene hierarchy context menu you can quickly create a UI box input filter setup:
- Makinom > UI Box > Input Filter > Add Input Filters
Adds a new game object with a UI Box Input Filters component. - Makinom > UI Box > Input Filter > Add Input Filters (Scroll Horizontal)
Adds a new game object with a UI Box Input Filters component and a horizontal scroll view setup.
UI Box Multi Input Filters Component #
The UI Box Multi Input Filters component can optionally be used to manage multiple UI Box Input Filters components. I.e. you can combine multiple sets of filters for more complex filtering, e.g. having one set of filters require one of their filters to be active, while another requires all.
The component will find all UI Box Input Filter components attached to itself or it’s child objects. You can optionally also add UI box input filters directly to the component for management, e.g. in case filters are not placed on child objects of the component’s game object or you want to guarantee their order for controls.
Multi input filters can take control of the UI box input filters they control and overrule their input keys.
Using the scene hierarchy context menu you can quickly create a UI box input filter setup:
- Makinom > UI Box > Input Filter > Add Multi Input Filters
Adds a new game object with a UI Box Multi Input Filters component.