Skip to main content

SettingsPanel

A class in Root.Township, the global namespace.

In-world settings board that slides down when a lever is pulled and shows that lever's board, then slides back up when every lever is off. Client side.

Constructors​

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

Fields​

11 private and internal fields
MemberWhat it is
private float animationProgressCurrent slide position, 0 up to 1 down.
private SettingsPanel.SettingsPanelConfiguration currentPanelBoard and lever pair now shown.
private Coroutine currentSlideAnimationRunning slide coroutine, or null.
private Coroutine currentSwitchAnimationRunning board switch coroutine, or null.
private SettingDescriptionPanel descriptionPanelBacking field for DescriptionPanel.
private bool isSlidingDownTestInspector button to test sliding down.
private bool isSlidingUpTestInspector button to test sliding up.
private SettingsPanel.SettingsPanelConfiguration[] panelsEach board with the lever that opens it.
private Transform panelTransformTransform moved up and down.
private AnimationCurve slideAnimationCurve from slide progress to the panel's local height.
private float slideDurationHow long a full slide takes, in seconds.

Properties​

MemberWhat it is
SettingDescriptionPanel DescriptionPanel { get; }The description panel boards use to show the hovered setting.
bool IsDown { get; private set; }True once the panel has finished sliding down. False while moving.
bool IsUp { get; private set; }True once the panel has finished sliding up. False while moving.

Methods​

9 private and internal methods
MemberWhat it is
private void HandleLeverChanged(SelectionLever lever, int oldValue, int newValue)Lever handler: pulling a lever turns the others off and switches to its board; once all levers are off the panel slides up.
private void OnValidate()Editor: runs the test slide and switch buttons and previews animationProgress.
private void PositionPanel(float progress)Sets the panel's local height from slideAnimation at the given progress.
private IEnumerator Slide(float targetProgress) (iterator)Coroutine that moves the panel to fully up (0) or down (1) over slideDuration, then updates IsUp and IsDown.
private void Start()Puts the panel up, hides every board and subscribes to each lever.
private void StartSlideDown()Starts sliding the panel down, replacing any slide in progress.
private void StartSlideUp()Starts sliding the panel up, replacing any slide in progress.
private void SwitchToBoard(SettingsPanel.SettingsPanelConfiguration panel)Shows the given board: slides down if it's already current, else slides up, swaps boards and slides down again.
private IEnumerator SwitchToBoardCoroutine(SettingsPanel.SettingsPanelConfiguration panel) (iterator)Waits for the current slide, hides the old board, shows the new one and slides down.

Used in​

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