Skip to main content

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.

Constructors​

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

Fields​

17 private and internal fields
MemberWhat it is
private float anglePerSideDegrees between drum faces (360 divided by numberOfSides).
private float currentAngleThe drum's current rotation in degrees.
private int currentlySelectedPanelIndex of the drum face that is selected.
private float debugLeverAngleLever angle used instead of the real one when isUsingDebugLeverAngle is on.
private bool isUsingDebugLeverAngleDebug option to drive the drum from debugLeverAngle.
private bool jumpToSelectedInspector button that snaps the drum to the selected face.
private SelectionLever leverThe lever that drives the drum. Must have one selection option, in the middle.
private static Logger loggerNLog logger for this class.
private float middleAngleThe lever's resting angle.
private float negativeRangeLever travel below the middle angle.
private int numberOfSidesNumber of faces on the drum. Default 6.
private float positiveRangeLever travel above the middle angle.
private Transform scrollerThe drum transform that rotates.
private AnimationCurve speedCurveMaps how far the lever is pushed (0 to 1) to spin speed.
private float speedMultiplierMultiplier on the spin speed.
private List<TextRenderer> textSidesText on each drum face.
private IUnityUpdateMethod updateThe registered late update while the lever is held.

Methods​

MemberWhat it is
protected override void FinishedRefresh()After values load, snaps the drum to the selected side and fills in the side texts.
protected override void OnValidate()Editor: names the object, logs an error if the lever has more than one option, and handles the jump button.
protected override void Setup()Works out the angle per side and the lever's ranges from its settings, then runs the base setup.
protected override void UpdateText()Empty; the drum uses UpdateTextSides instead of the single value text.
9 private and internal methods
MemberWhat 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.