Game.UI.Editor.ItemPickerFooter
Assembly:
Game (inferred)
Namespace:
Game.UI.Editor
Type:
class (public)
Base:
Widget
Implements: ISettable, IWidget, IJsonWritable
Summary:
ItemPickerFooter is a UI widget used as the footer for an item picker in the editor UI. It keeps cached copies of the current adapter length and column count (m_Length and m_ColumnCount), observes the provided IAdapter for changes, exposes an adapter property to connect to the data source, and supports JSON-based persistence via ISettable / IJsonWritable. The widget's Update method detects when the adapter's length or columnCount change and flags Property changes so the UI can be refreshed; WriteProperties serializes the cached length and columnCount.
The class also defines a nested IAdapter interface that the data source must implement: - int length { get; } — total number of items - int columnCount { get; set; } — current number of columns shown (modifiable)
Fields
-
private int m_Length
Tracks the last-known adapter.length value. Used to detect changes and trigger property updates. -
private int m_ColumnCount
Tracks the last-known adapter.columnCount value. Used to detect changes and trigger property updates and for serialization.
Properties
-
public IAdapter adapter { get; set; }
The data source adapter for the item picker footer. The adapter must implement the nested IAdapter interface. ItemPickerFooter reads adapter.length and adapter.columnCount during Update and SetValue. -
public bool shouldTriggerValueChangedEvent => true
A read-only property (expression-bodied) indicating that the widget should trigger value-changed events. Always returns true.
Constructors
public ItemPickerFooter()
Default parameterless constructor (implicit if not defined). Initialize the widget; no custom constructor logic is present in the source.
Methods
-
public void SetValue(IJsonReader reader)
Reads an integer value from the provided IJsonReader and assigns it to adapter.columnCount. Used to restore state from JSON (implements ISettable). If adapter is null, calling this method will throw a NullReferenceException — caller must ensure adapter is assigned. -
protected override WidgetChanges Update()
Overrides Widget.Update. Compares adapter.length to the cached m_Length and adapter.columnCount to m_ColumnCount. If either differs, sets the WidgetChanges.Properties flag and updates the cached fields. Returns the accumulated WidgetChanges. This keeps the footer in sync with the adapter and notifies the UI system when properties change. -
protected override void WriteProperties(IJsonWriter writer)
Overrides Widget.WriteProperties to serialize the cached values. Writes two properties into the JSON writer: - "length" : m_Length
- "columnCount" : m_ColumnCount This implements the IJsonWritable contract so the footer's state can be saved.
Usage Example
// Example adapter implementing the nested IAdapter:
private class MyAdapter : ItemPickerFooter.IAdapter
{
public int length { get; private set; }
private int m_columnCount;
public int columnCount
{
get => m_columnCount;
set => m_columnCount = value;
}
public MyAdapter(int length, int columns)
{
this.length = length;
this.m_columnCount = columns;
}
}
// Creating and wiring the footer:
var footer = new ItemPickerFooter();
footer.adapter = new MyAdapter(length: 100, columns: 3);
// When loading state from JSON:
footer.SetValue(jsonReader); // expects an int written for columnCount
// During the widget update loop, Update() will detect changes in adapter.length
// or adapter.columnCount and flag WidgetChanges.Properties so the UI is refreshed.
// When saving state to JSON:
footer.WriteProperties(jsonWriter); // writes "length" and "columnCount"