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.
- Listed in Global namespace: S
- Inherits or implements
MonoBehaviour - Nested types
SettingsPanelConfiguration
Constructors
| Member | What it is |
|---|---|
SettingsPanel() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
11 private and internal fields
| Member | What it is |
|---|---|
private float animationProgress | Current slide position, 0 up to 1 down. |
private SettingsPanel.SettingsPanelConfiguration currentPanel | Board and lever pair now shown. |
private Coroutine currentSlideAnimation | Running slide coroutine, or null. |
private Coroutine currentSwitchAnimation | Running board switch coroutine, or null. |
private SettingDescriptionPanel descriptionPanel | Backing field for DescriptionPanel. |
private bool isSlidingDownTest | Inspector button to test sliding down. |
private bool isSlidingUpTest | Inspector button to test sliding up. |
private SettingsPanel.SettingsPanelConfiguration[] panels | Each board with the lever that opens it. |
private Transform panelTransform | Transform moved up and down. |
private AnimationCurve slideAnimation | Curve from slide progress to the panel's local height. |
private float slideDuration | How long a full slide takes, in seconds. |
Properties
| Member | What 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
| Member | What 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: