CustomScroller
A class in Root.Township, Alta.Menu.
A rotating drum menu driven by a SelectionLever: holding the lever off-centre spins the drum and steps through a list of string values. Used by the server creator.
- Listed in Menus, UI and platforms
- Inherits or implements
MonoBehaviour
Constructors
| Member | What it is |
|---|---|
CustomScroller() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
20 private and internal fields
| Member | What it is |
|---|---|
private float anglePerSide | Degrees of drum rotation per side (360 divided by numberOfSides). |
private float currentAngle | Current drum rotation in degrees. |
private int currentlySelectedPanel | Which physical drum side is facing the player. |
private float debugLeverAngle | Lever angle used instead of the real one when isUsingDebugLeverAngle is on. |
private bool isRefreshing | When set, stops UpdateScroller and Refresh from doing anything. |
private bool isUsingDebugLeverAngle | Editor testing: use debugLeverAngle instead of the lever. |
private bool jumpToSelected | Inspector button that runs JumpToSelected. |
private SelectionLever lever | The selection lever that drives the scroller. |
private static Logger logger | NLog logger for this class. |
private float middleAngle | The lever's resting angle (its first selection angle). |
private float negativeRange | How far the lever can move below middleAngle. |
private int numberOfSides | Number of sides on the drum (default 6). |
private float positiveRange | How far the lever can move above middleAngle. |
private string[] possibleValues | Backing field for PossibleValues. |
private Transform scroller | The drum transform that gets rotated. |
private AnimationCurve speedCurve | Maps how far the lever is pushed (0 to 1) to spin speed. |
private float speedMultiplier | Scales the spin speed from speedCurve. |
private List<TextRenderer> textSides | Text renderers on each side of the drum. |
private IUnityUpdateMethod update | Handle for the registered late update method while the lever is held. |
private TextRenderer valueText | Optional text that shows the selected value. |
Properties
Events
| Member | What it is |
|---|---|
event Action<CustomScroller, int> IndexChanged | Raised with the scroller and new index whenever the selection changes. |
Methods
9 private and internal methods
| Member | What it is |
|---|---|
private void Awake() | Hooks the lever handle's interaction start and end to start and stop the scroller update. |
private void JumpToSelected() | Snaps the drum rotation to the selected panel. |
private void SetScrollerRotation(float angle) | Sets the drum's local rotation around X to the given angle. |
private void Start() | Works out the angle per side and the lever's ranges around its middle position, then snaps to the selection. |
private void StartUpdatingScroller(Interactable arg1, Interactor arg2) | Registers UpdateScroller in late update when the lever is grabbed. |
private void StopUpdatingScroller(Interactable arg1, Interactor arg2) | Stops the late update and snaps to the selected panel when the lever is let go. |
private void UpdateScroller() | Spins the drum based on how far the lever is from centre (through speedCurve), and steps the selection when the drum passes a side. |
private void UpdateScroller(int direction) | Spins the drum based on how far the lever is from centre (through speedCurve), and steps the selection when the drum passes a side. |
private int WrapIndex(int number, int length) | Wraps a number into 0 to length, handling negatives. |
Used in
Members of other types that take, return or hold a CustomScroller: