Skip to content

Game.UI.Widgets.ButtonRow

Assembly:
Assembly-CSharp (typical game assembly; actual assembly may vary)

Namespace:
Game.UI.Widgets

Type:
class

Base:
Widget

Summary:
A simple container widget that holds an ordered array of Button children. ButtonRow forwards visibility/activity queries to its children and provides a simple factory helper. When the children array is replaced, it applies container defaults and marks the children as changed so the parent/layout can react.


Fields

  • private Button[] m_Children
    Holds the child buttons. Initialized to Array.Empty

Properties

  • public Button[] children { get; set; }
    Accessor for the child Button array. The setter compares the new array to the current m_Children; if different it calls ContainerExtensions.SetDefaults(value) to apply default settings to the buttons, assigns m_Children, and calls SetChildrenChanged() to notify the widget system of the change.

  • public override bool isVisible => children.Any((Button c) => c.isVisible)
    Reports visible status based on whether any child Button reports isVisible.

  • public override bool isActive => children.Any((Button c) => c.isActive)
    Reports active status based on whether any child Button reports isActive.

  • public override IList<IWidget> visibleChildren => children
    Exposes the children array as the list of visible children (note: this returns the entire children array, not a filtered subset).

Constructors

  • public ButtonRow()
    No explicit constructor is defined in the source; the default parameterless constructor is used. The m_Children field is initialized to an empty Button[].

Methods

  • public override WidgetChanges UpdateVisibility()
    Overrides Widget.UpdateVisibility(). Calls base.UpdateVisibility() then iterates over visibleChildren.OfType(), calling UpdateVisibility() on each child widget and OR-ing the results into the returned WidgetChanges value. This propagates visibility updates to child widgets and collects any change flags they produce.

Remarks: - The children setter calls ContainerExtensions.SetDefaults(value) — that helper is external to this class and is used to normalize/setup child widgets when they are placed into a container. - SetChildrenChanged() is called after replacing the children array; that method (inherited from Widget/Container) likely marks layout and redraw state as dirty so the UI can reflow. - visibleChildren returns the raw children array; callers should be aware it's not filtered by the child's isVisible property (the class's isVisible property is computed from children, but visibleChildren itself is the children collection).

Usage Example

// Create some buttons (Button is assumed to implement IWidget)
var b1 = new Button { /* initialize button 1 */ };
var b2 = new Button { /* initialize button 2 */ };

// Use the factory helper to create a ButtonRow
var row = ButtonRow.WithChildren(new[] { b1, b2 });

// Alternatively set children directly (will call SetDefaults and mark children changed)
row.children = new[] { b1, b2 };

// When updating UI, propagate visibility checks/updates
var changes = row.UpdateVisibility();