ScrollerEnumMenuSetting
A class in Root.Township, Alta.Menu.
Client menu control for a choice setting shown on a rotating drum. Holding a lever off centre spins the drum and steps through the values.
- Listed in Menus, UI and platforms
- Inherits or implements
EnumMenuSettingBase
Constructors
| Member | What it is |
|---|---|
ScrollerEnumMenuSetting() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
17 private and internal fields
| Member | What it is |
|---|---|
private float anglePerSide | Degrees between drum faces (360 divided by numberOfSides). |
private float currentAngle | The drum's current rotation in degrees. |
private int currentlySelectedPanel | Index of the drum face that is selected. |
private float debugLeverAngle | Lever angle used instead of the real one when isUsingDebugLeverAngle is on. |
private bool isUsingDebugLeverAngle | Debug option to drive the drum from debugLeverAngle. |
private bool jumpToSelected | Inspector button that snaps the drum to the selected face. |
private SelectionLever lever | The lever that drives the drum. Must have one selection option, in the middle. |
private static Logger logger | NLog logger for this class. |
private float middleAngle | The lever's resting angle. |
private float negativeRange | Lever travel below the middle angle. |
private int numberOfSides | Number of faces on the drum. Default 6. |
private float positiveRange | Lever travel above the middle angle. |
private Transform scroller | The drum transform that rotates. |
private AnimationCurve speedCurve | Maps how far the lever is pushed (0 to 1) to spin speed. |
private float speedMultiplier | Multiplier on the spin speed. |
private List<TextRenderer> textSides | Text on each drum face. |
private IUnityUpdateMethod update | The registered late update while the lever is held. |
Methods
9 private and internal methods
| Member | What it is |
|---|---|
private void Awake() | Starts and stops scrolling when the lever handle is grabbed and let go. |
private void JumpToSelected() | Rotates the drum to show the selected side squarely. |
private void SetScrollerRotation(float angle) | Sets the drum's local x rotation. |
private void StartUpdatingScroller(Interactable arg1, Interactor arg2) | Starts calling UpdateScroller every late update while the lever is held. |
private void StopUpdatingScroller(Interactable arg1, Interactor arg2) | Stops the late update and snaps the drum to the selected side. |
private void UpdateScroller() | Spins the drum by the lever's angle through speedCurve; when it passes a side, steps the value and saves it. |
private void UpdateScroller(int direction) | Spins the drum by the lever's angle through speedCurve; when it passes a side, steps the value and saves it. |
private void UpdateTextSides() | Writes the previous, current and next values on the three drum faces around the selected one. |
private int WrapIndex(int number, int length) | Wraps a number into the range 0 to length minus 1. |