StandardFloatAsEnum
A class in Root.Township, Alta.Menu.
Client menu control that shows a float setting as a drum of named choices, spun with a lever like ScrollerEnumMenuSetting. The choices come from an EnumFloatGameSettingsAccess or its own lists.
- Listed in Menus, UI and platforms
- Inherits or implements
MenuGameSetting<FloatGameSettingsAccess>
Constructors
| Member | What it is |
|---|---|
StandardFloatAsEnum() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
| Member | What it is |
|---|---|
protected bool isRefreshing | True while the current choice is being loaded; blocks changes. |
22 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 EnumFloatGameSettingsAccess enumSettings | The setting as an EnumFloatGameSettingsAccess, when it is one; supplies the values and names. |
private bool isUsingDebugLeverAngle | Debug option to drive the drum from debugLeverAngle. |
private bool isUsingEnumSettings | True when the choices come from enumSettings instead of this component's lists. |
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 float[] possibleValues | Float values for each choice when no enum settings source is used. Default 0.5, 1, 2, 4. |
private string[] possibleValuesNames | Names shown for each choice when no enum settings source is used. |
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. |
private TextRenderer valueText | Serialized text field that this class never writes to. |
Properties
| Member | What it is |
|---|---|
int CurrentIndex { get; protected set; } | Index of the selected choice, or -1 if the setting's value matches none of them. |
Methods
12 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 FinishedRefresh() | Snaps the drum to the selected face and fills in the face texts. |
private int GetIndex() | Finds the choice whose value is about equal to the setting's current value; -1 if none. |
private void JumpToSelected() | Rotates the drum to show the selected face squarely. |
private void RefreshValues() | Sets CurrentIndex from the setting's value, then calls FinishedRefresh. |
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 face. |
private void UpdateScroller() | Spins the drum by the lever's angle through speedCurve; when it passes a face, steps the choice and saves it. |
private void UpdateScroller(int direction) | Spins the drum by the lever's angle through speedCurve; when it passes a face, steps the choice and saves it. |
private void UpdateTextSides() | Writes the previous, current and next choice names 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. |