Skip to main content

ServerSelectionDisplay

A class in Root.Township, the global namespace.

Main menu server list laid out along a spline. Scrolling moves the elements along it; the one nearest the selection point is selected. Client only.

Constructors​

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

Fields​

14 private and internal fields
MemberWhat it is
private AltaEvent elementSelectedEvent raised whenever a new element becomes selected.
private bool isSelectingFirstInspector button that runs Setup and SelectFirst in the editor.
private float maximumEnabledTimeElements past this spline position are hidden. Default 0.7.
private float maxSelectionDeltaHow close (in spline position) an element must be to selectedTime to be selected. Default 0.15.
private float minimumEnabledTimeElements before this spline position are hidden. Default 0.2.
private float moveToTimeAnimationDurationSeconds a non-instant SelectElement slide takes. Default 2.
private Coroutine moveToTimeCoroutineThe running MoveToTime slide, if any.
private float selectedTimeSpline position (0 to 1) of the selection point. Default 0.55.
private Transform selectorTransform placed at the selection point on the spline.
private List<ServerElement> serverElementsThe elements on the display in order. Filled by AddServerElement.
private float spacingSpline distance between neighbouring elements. Default 0.05.
private BezierSpline splineThe Bezier spline the elements are laid along.
private float startValueLowest allowed scroll value, set by CalculateStartValue.
private float timeCurrent scroll position along the spline. Backing field for Value.

Properties​

MemberWhat it is
ServerElement CurrentSelection { get; private set; }The element at the selection point, or null.
List<ServerElement> ServerElements { get; }The elements in display order.
float Value { get; set; }Scroll position along the spline, clamped to the list's range. Setting it stops any scroll animation.

Events​

MemberWhat it is
event SelectedElementChanged SelectedChangedRaised with the old and new selection.

Methods​

MemberWhat it is
void AddServerElement(ServerElement serverElement)Adds an element to the end of the list.
void RemoveServerElement(ServerElement serverElement)Removes an element, clearing the selection first if it was selected.
void SelectElement(ServerElement serverElement, bool isInstant)Scrolls so an element sits at the selection point, instantly or animated.
void SelectFirst()Scrolls to the first element.
11 private and internal methods
MemberWhat it is
private void CalculateStartValue()Sets the lowest scroll value from the element count and spacing, so the last element can reach the selection point.
private IEnumerator MoveToTime(float targetTime, float moveToTimeAnimationDuration) (iterator)Coroutine that slides the scroll value to a target over a duration. Started by SelectElement when not instant.
private void OnDrawGizmos()Editor: draws red spheres on the spline at the edges of the selection window.
private void OnSelectionChanged(ServerElement oldSelected)In play mode, raises SelectedChanged and, when something is selected, the elementSelected event.
private void OnValidate()Editor: clamps the scroll value and handles the Select First inspector button.
private void PositionTransformAtTime(float targetTime, Transform target)Places a transform on the spline at a position, facing along it, or hides it outside the enabled range.
private void Setup()Recalculates the start value and puts the selector at the selection point on the spline.
private void Start()Calls Setup.
private void StopCurrentMoveToTimeAnimation()Stops a running MoveToTime slide.
private void Update()Calls UpdateTargets every frame.
private void UpdateTargets()Positions every element along the spline, sets which are interactable, and selects the one closest to the selection point.

Used in​

Members of other types that take, return or hold a ServerSelectionDisplay: