Skip to main content

InGameInspectorWheel

A class in Root.Township, the global namespace.

A physical selection wheel on the debug InGameInspector. It snaps its hinge to evenly spaced points and plays a click as the selected point changes.

Constructors​

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

Fields​

26 private and internal fields
MemberWhat it is
private float anglesPerSectionDegrees between snap points. Only set in OnDrawGizmos here.
private Transform debugIconInspector-assigned transform for debugging icons. Not used in this code.
private int debugIndexInspector-assigned debug index. Not used in this code.
private int dissapearingPointIndexIndex of the snap point opposite the selection.
private float dissappearingAngleAngle opposite the selection arrow.
private int handleInteractorsHow many hands hold the wheel's handles.
private Interactable[] handlesGrab points that turn the wheel.
private Rigidbody hingeRigidbody of the wheel that spins on its hinge.
private Material iconMaterialMaterial for the wheel icons. Not used in this code.
private Transform iconParentParent for the wheel icons. Not used in this code.
private float iconRadiusDistance of the snap points from the wheel centre, used by the gizmos.
private float iconSizeSize of the wheel icons. Not used in this code.
private float iconXOffsetSideways offset of the snap point gizmos.
private InGameInspector inspectorThe InGameInspector this wheel belongs to.
private bool isInitializedFixedUpdate does nothing until this is true. Nothing in this code sets it, so the snapping never runs.
private bool isPlayingSoundsWhether to play the wheel click when the selection changes.
private bool isSnappingToPointsWhether the wheel is pulled towards the nearest snap point.
private float minAngleDifferenceWithin this many degrees of a point, and below minVelocity, the wheel stops.
private float minVelocityAngular speed under which the wheel may stop on a point.
private int numberOfSnapPointsHow many points the wheel snaps to.
private int[] pointsNot used in this code.
private AnimationCurve rotationEffectCurve of snap pull strength against distance from the point, as a share of a section.
private float rotationMultiplierScales the snap pull.
private float selectionAngleCurrent wheel angle under the selection arrow.
private Transform selectionArrowFixed marker whose position on the wheel picks the selected point.
private int selectionPointIndexIndex of the selected snap point.

Properties​

MemberWhat it is
bool IsInteractedWith { get; }True while any of the wheel's handles is held.

Methods​

13 private and internal methods
MemberWhat it is
private void CalculateSelectionAngle()Works out the wheel angle under the selection arrow, and the angle opposite it.
private void ConvertToPositiveAngle(ref float angle)Adds 360 to an angle until it is no lower than minus half a section.
private void DrawSphereAtAngle(float angle, float xOffset)Editor gizmo helper: draws a small sphere on the wheel rim at an angle.
private void FixedUpdate()Once initialized, updates the selection and pushes the hinge towards the nearest snap point, stopping it when close and slow.
private void OnDestroy()Destroys the handle objects along with the wheel.
private void OnDisable()Stops counting handle grabs.
private void OnDrawGizmos()Editor only: draws the snap points, selected point and opposite point as coloured spheres.
private void OnEnable()Starts counting grabs and releases on each handle.
private void OnValidate()Keeps numberOfSnapPoints from going below zero.
private void RemoveInteractedWith(Interactable interactable, Interactor interactor)Counts one handle released.
private void SetInteractedWith(Interactable interactable, Interactor interactor)Counts one handle grabbed.
private void SetSelectionPoint()Picks the snap point nearest the arrow, plays the wheel sound when it changes, and tracks the opposite point.
private void Start()Finds the InGameInspector in the parents.