Skip to main content

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.

Constructors​

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

Fields​

20 private and internal fields
MemberWhat it is
private Renderer androidDefaultTextSidesDefault text sides renderer for Android.
private float anglePerSideDegrees per wheel side.
private float currentAngleThe wheel's current rotation.
private int currentIndexBacking field for CurrentIndex.
private int currentlySelectedPanelWhich wheel side shows the selected value.
private Renderer defaultTextSidesRenderer with placeholder text, hidden once values load.
private bool isLocalPlayerOnlyIf true, only the local player's grabs turn the wheel.
private bool jumpToSelectedEditor button that jumps to the selected side.
private SelectionLever leverThe lever that drives the wheel.
private static Logger loggerLogger for setup errors.
private float middleAngleThe lever's rest angle.
private float negativeRangeLever travel below the rest angle.
private int numberOfSidesHow many sides the wheel has (default 6).
private float positiveRangeLever travel above the rest angle.
private List<string> possibleValuesThe values to scroll through.
private Transform scrollerThe transform that rotates.
private AnimationCurve speedCurveMaps lever push (0 to 1) to turn speed.
private float speedMultiplierMultiplier on turn speed.
private TextRenderer[] textSidesText on each side of the wheel.
private IUnityUpdateMethod updateHandle for the registered LateUpdate method.

Properties​

MemberWhat it is
int CurrentIndex { get; private set; }Index of the selected value. Raises UpdatedValue when it changes.

Events​

MemberWhat it is
event Action<int> UpdatedValueRaised with the new index when the selection changes.

Methods​

MemberWhat it is
void GoToNextValue()Selects the next value, wrapping round.
void GoToPreviousValue()Selects the previous value, wrapping round.
15 private and internal methods
MemberWhat 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: