Skip to main content

PanelComponent

An abstract class in Root.Township, Alta.Meta.UI.

Base for components that fill a meta UI Panel with data. Refreshes when the panel opens if marked stale, and marks itself stale on a timer (30 seconds by default).

Constructors​

MemberWhat it is
protected PanelComponent()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

MemberWhat it is
protected static Logger loggerNLog logger shared by panel components.
protected bool needsToRefreshDataTrue when data should be reloaded on the next panel state change.
protected Panel panelThe panel this component belongs to (set in the editor).
2 private and internal fields
MemberWhat it is
private Timeline.IEntry entryThe scheduled refresh on the Timeline.
private float refreshTimerSeconds between automatic data refreshes. Default 30; 0 or less turns them off.

Properties​

MemberWhat it is
Panel Panel { get; }The panel this component belongs to.

Methods​

MemberWhat it is
void ForceRefreshOnNextLoad()Refreshes now if the panel is open, otherwise refreshes the next time it opens.
virtual void RefreshData()Override to reload the panel's data. Empty in the base.
protected virtual void HandleStateChange(Panel panel)Hook for subclasses, called each time the panel opens or closes.
4 private and internal methods
MemberWhat it is
private void Awake()Hooks the panel's state changes and, if refreshTimer is above 0, schedules RefreshAgain.
private void HandlePanelStateChange(Panel panel)On any panel state change: runs RefreshData if a refresh is pending, then HandleStateChange.
private void OnDestroy()Cancels the scheduled refresh.
private void RefreshAgain()Timer callback: refreshes now if the panel is open, otherwise on next open, then schedules itself again.

Used in​

Members of other types that take, return or hold a PanelComponent: