ScrollerSelector
A class in Root.Township, Alta.Menu.
Menu wheel that scrolls through a list of text values with a lever. Gets its values from an IProvideEnumerable<string> on the same object.
- Listed in Menus, UI and platforms
- Inherits or implements
MonoBehaviour
Constructors
| Member | What it is |
|---|---|
ScrollerSelector() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
20 private and internal fields
| Member | What it is |
|---|---|
private Renderer androidDefaultTextSides | Default text sides renderer for Android. |
private float anglePerSide | Degrees per wheel side. |
private float currentAngle | The wheel's current rotation. |
private int currentIndex | Backing field for CurrentIndex. |
private int currentlySelectedPanel | Which wheel side shows the selected value. |
private Renderer defaultTextSides | Renderer with placeholder text, hidden once values load. |
private bool isLocalPlayerOnly | If true, only the local player's grabs turn the wheel. |
private bool jumpToSelected | Editor button that jumps to the selected side. |
private SelectionLever lever | The lever that drives the wheel. |
private static Logger logger | Logger for setup errors. |
private float middleAngle | The lever's rest angle. |
private float negativeRange | Lever travel below the rest angle. |
private int numberOfSides | How many sides the wheel has (default 6). |
private float positiveRange | Lever travel above the rest angle. |
private List<string> possibleValues | The values to scroll through. |
private Transform scroller | The transform that rotates. |
private AnimationCurve speedCurve | Maps lever push (0 to 1) to turn speed. |
private float speedMultiplier | Multiplier on turn speed. |
private TextRenderer[] textSides | Text on each side of the wheel. |
private IUnityUpdateMethod update | Handle for the registered LateUpdate method. |
Properties
| Member | What it is |
|---|---|
int CurrentIndex { get; private set; } | Index of the selected value. Raises UpdatedValue when it changes. |
Events
| Member | What it is |
|---|---|
event Action<int> UpdatedValue | Raised with the new index when the selection changes. |
Methods
| Member | What it is |
|---|---|
void GoToNextValue() | Selects the next value, wrapping round. |
void GoToPreviousValue() | Selects the previous value, wrapping round. |
15 private and internal methods
| Member | What it is |
|---|---|
private void Awake() | Hooks the lever handle, loads the values and works out the lever's angle ranges. |
private void FinishedRefresh() | Snaps the wheel to the selected side and refreshes the side texts. |
private void JumpToSelected() | Rotates the wheel to show the selected side. |
private void OnValidate() | Editor: warns if the lever has more than one option, and jumps to the selected side when that button is ticked. |
private void Refresh() | Wraps CurrentIndex back into range. |
private void RefreshValues(IEnumerable<string> values) | Replaces the value list, keeping the same value selected if it's still there. |
private void SetScrollerRotation(float angle) | Sets the wheel's rotation on X. |
private void StartUpdatingScroller(Interactable interactable, Interactor interactor) | Starts turning the wheel each LateUpdate while the lever is held (local player only by default). |
private void StopUpdatingScroller(Interactable interactable, Interactor interactor) | Stops turning and snaps to the selected side. |
private void UpdateScroller() | Turns the wheel at a speed from how far the lever is pushed, and steps the selection as it passes each side. |
private void UpdateScroller(int direction) | Turns the wheel at a speed from how far the lever is pushed, and steps the selection as it passes each side. |
private void UpdateTextSides() | Writes the previous, current and next values on the three sides facing the player. |
private void UpdateValues(IProvideEnumerable<string> valueProvider) | Reloads the values when the provider says they changed. |
private int WrapEnumIndex(int index) | Wraps an index into the value list's range. |
private int WrapIndex(int number, int length) | Wraps a number into 0 to length minus one. |
Used in
Members of other types that take, return or hold a ScrollerSelector: