Skip to main content

QuickAccessMenuController

A class in Root.Township, Alta.QuickAccessActions.

Client: the radial quick-access menu on one hand. Holding the menu button spawns bubbles around the hand; releasing runs the closest bubble's action. A controller extension, set up only for the local player.

Constructors​

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

Fields​

16 private and internal fields
MemberWhat it is
private QuickAccessMenuBubble cachedClosestMenuBubble currently marked as selected, or null.
private GameObject currentCenterTitleBackgroundBackground object behind the centre title.
private int currentNestingLevelDeepest nesting level among open bubbles; widens the follow distance.
private QuickAccessMenuAction[] devQuickAccessMenusExtra actions shown only to developers.
private bool hasDevToolsTrue in the editor or when the signed-in user has the developer role.
private bool isCurrentlyLerpingPositionTrue while the menu is moving to catch up with the hand.
private bool isCurrentlyLerpingRotationTrue while the menu is turning to face the camera.
private bool isOpenTrue while the menu is shown.
private static Logger loggerNLog logger for this class.
private QuickAccessMenuController otherControllerThe other hand's menu controller, so only one menu is open at a time.
private GameObject quickAccessMenuParentPrefabPrefab created as MenusParent.
private QuickAccessMenuAction[] quickAccessMenusThe actions shown as bubbles.
private const float RadialSpaceInDegreesFull circle the bubbles are spread over (360).
private Transform rootTransformThe player's transform; the menu parent is parented to it.
private Coroutine runningInputThe running WaitForInput coroutine.
private readonly List<QuickAccessMenuBubble> spawnedMenusBubbles currently open, including nested ones.

Properties​

MemberWhat it is
TextRenderer CenteredTitleDisplay { get; private set; }Text in the middle of the menu that shows the selected bubble's title.
Transform MenusParent { get; private set; }Transform the bubbles spawn under; follows the hand while open.
QuickAccessMenuSettings Settings { get; private set; }The global QuickAccessMenuSettings.

Events​

MemberWhat it is
event Action<QuickAccessMenuBubble> newBubbleMarkedRaised when a new bubble is selected. Cleared when the menu closes.

Methods​

MemberWhat it is
void AddNested(IEnumerable<QuickAccessMenuBubble> newBubbles)Adds a nested submenu's bubbles to the selectable list.
override void InitializeControllerExtension()Local player only: creates the menu parent, binds the menu buttons, works out dev access and initializes every action.
void RemoveNested(IEnumerable<QuickAccessMenuBubble> newBubbles)Removes a nested submenu's bubbles from the selectable list.
void SetCenteredTitle(string title)Shows a title in the menu's centre, or hides the text when it's empty.
25 private and internal methods
MemberWhat it is
private void Activate()Closes any open menu on either hand and spawns the bubbles around the grip point, unless both menu buttons are held with accessibility on.
private void ButtonPress(PlayerInput playerInput)Opens the menu when the quick-access button is pressed.
private void ButtonRelease(PlayerInput playerInput, bool isDisabling)Runs the selected bubble on release, or just closes if the input was disabled.
private static Quaternion CalculateAngleStepBetweenBubbles(Quaternion cameraRotation, int bubbleCount)Rotation between neighbouring bubbles: 360 degrees split by the bubble count, around the camera's view axis.
private void CloseAndClear()Closes the menu: stops input, releases every bubble, clears newBubbleMarked subscribers and hides the title.
private void CloseAndTryActivateSelectedMenu()Runs the selected bubble's action (playing select effects on success), then closes both hands' menus.
private bool ClosestMenuHasChanged(Vector3 controllerPosition, out QuickAccessMenuBubble foundMenu)Finds the bubble nearest the hand within the max distance; true if it differs from the cached one.
private void DeactivateCenterMenu()Hides the title background and clears the title.
private string GetFormattedTitle(string title)Truncates a title to the max character count with an ellipsis, logging a warning.
private Quaternion GetNewRotation(Quaternion rotation, Quaternion targetRotation)Rotates towards the target, starting to lerp when the angle passes the max and snapping when close.
private int GetNonIgnoredBubbleCount()Counts actions that aren't ignored, including dev actions when dev tools are on.
private static Quaternion GetTargetRotation(Vector3 position)Rotation that makes the menu face the camera.
private Quaternion GetUpdatedTargetRotation(Quaternion currentRotation)Target rotation lerped from the current one by the settings' rotation speed.
private void InitializeCenterTitleBackground()Creates the title background under the menu parent once.
private bool IsPerformingAccessibleDocksInput()True when accessibility is on and both hands hold the menu button (the accessible docks gesture), which blocks the menu.
private void MarkSelected(Vector3 controllerPosition)Marks the bubble nearest the hand as selected, or unmarks when none is in range.
private void OnDestroy()Closes the menu.
private void PositionMenuParent(Transform controllerTransform)Moves the menu parent to the hand and turns it towards the camera.
private void SpawnBubbles(QuickAccessMenuAction[] menus, Quaternion step, ref Vector3 fromOrigin)Spawns a bubble for each non-ignored action, stepping around the circle.
private void ToggleButtonPress(PlayerInput playerInput)Toggle input: opens the menu, or if open runs the selected bubble and closes.
private void UpdateMarkClosestMenu(QuickAccessMenuBubble newClosestMenu)Moves the selection mark to a new bubble and raises newBubbleMarked.
private void UpdateNestingLevel()Sets the nesting level to the deepest bubble's level.
private void UpdatePosition(Vector3 controllerPosition)Lerps the menu towards the hand once it drifts past the allowed distance for the nesting level.
private void UpdateRotation()Turns the menu to keep facing the camera.
private IEnumerator WaitForInput(Transform controllerTransform) (iterator)Coroutine while open: each frame updates selection, rotation and position from the hand.

Used in​

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