PressableButton Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
The core behavior logic for a button that can be pressed, following the StatefulInteractable pattern.
[UnityEngine.AddComponentMenu("MRTK/UX/Pressable Button")]
public class PressableButton : MixedReality.Toolkit.StatefulInteractable
[UnityEngine.AddComponentMenu("MRTK/UX/Pressable Button")]
public class PressableButton : MixedReality.Toolkit.StatefulInteractable, MixedReality.Toolkit.Input.IXRProximityInteractable
[<UnityEngine.AddComponentMenu("MRTK/UX/Pressable Button")>]
type PressableButton = class
inherit StatefulInteractable
[<UnityEngine.AddComponentMenu("MRTK/UX/Pressable Button")>]
type PressableButton = class
inherit StatefulInteractable
interface IXRProximityInteractable
Public Class PressableButton
Inherits StatefulInteractable
Public Class PressableButton
Inherits StatefulInteractable
Implements IXRProximityInteractable
- Inheritance
-
UnityEngine.XR.Interaction.Toolkit.XRBaseInteractablePressableButton
- Attributes
-
UnityEngine.AddComponentMenuAttribute
- Implements
Remarks
This script does not make any assumptions about the visuals associated with this button. Any visuals script can listen to the GetSelectionProgress() value, or call PushPlaneLocalPosition() to obtain a selection progress value or a local displacement, respectively, to implement a visual layer.
Constructors
| Name | Description |
|---|---|
| PressableButton() | |
Properties
| Name | Description |
|---|---|
| DistanceSpaceMode |
Describes in which coordinate space the plane distances are stored and calculated |
| EndPushPlane |
Maximum push distance. Distance is relative to the pivot of either the moving visuals if there's any or the button itself. |
| EnforceFrontPush |
Ensures that the button can only be pushed from the front. Touching the button from the back or side is prevented. |
| IsProximityHovered |
Is this object in proximity of an active Interactor? |
| RejectXYRollOff |
Ensures that the button click event only fires if the push did not roll off the edge of the button in the XY plane. Defaults to true. |
| RejectZRollOff |
Ensures that the button click event only fires if the finger exited the button out the back instead of through the front plate. Defaults to false. |
| RollOffXYDepth |
/ If RejectXYRollOff is enabled, roll-offs will be rejected within this normalized press amount of the back plane. |
| SmoothSelectionProgress |
Should this button's selectionProgress be smoothed/animated, or absolute? |
| StartPushPlane |
The local z-position of the push plane. |
Methods
| Name | Description |
|---|---|
| ApplyRequiredSettings() |
Invoked on PressableButton, Awake(), and Reset() to apply required settings to this PressableButton instance. |
| Awake() |
A Unity event function that is called when an enabled script instance is being loaded. |
| CanClickOnFirstSelectEntered(SelectEnterEventArgs) |
This function determines whether the interactable should fire a click event at a given select event. Subclasses can override this to add additional requirements for full click/toggle activation, such as roll-off prevention. |
| CanClickOnLastSelectExited(SelectExitEventArgs) |
This function determines whether the interactable should fire a click event at a given deselect event. Subclasses can override this to add additional requirements for full click/toggle activation, such as roll-off prevention. |
| GetDistanceAlongPushDirection(Vector3) |
Returns the local/global distance along the push direction for the passed in world position |
| GetLocalPositionAlongPushDirection(Single) |
Returns local position along the push direction for the given local/global distance |
| GetSelectionProgress() |
Get the current selection progress of this StatefulInteractable. |
| IsSelectableBy(IXRSelectInteractor) | UnityEngine.XR.Interaction.Toolkit.XRBaseInteractable.IsSelectableBy(UnityEngine.XR.Interaction.Toolkit.IXRSelectInteractor) |
| OnDisable() |
A Unity event function that is called when the script component has been disabled. |
| OnHoverEntered(HoverEnterEventArgs) | UnityEngine.XR.Interaction.Toolkit.XRBaseInteractable.OnHoverEntered(UnityEngine.XR.Interaction.Toolkit.HoverEnterEventArgs) |
| OnHoverExited(HoverExitEventArgs) | UnityEngine.XR.Interaction.Toolkit.XRBaseInteractable.OnHoverExited(UnityEngine.XR.Interaction.Toolkit.HoverExitEventArgs) |
| OnProximityEntered(ProximityEnteredEventArgs) |
Registers the Detector as triggering proximity. |
| OnProximityExited(ProximityExitedEventArgs) |
Unregisters the Detector as triggering proximity. |
| ProcessInteractable(XRInteractionUpdateOrder+UpdatePhase) | UnityEngine.XR.Interaction.Toolkit.XRBaseInteractable.ProcessInteractable(UnityEngine.XR.Interaction.Toolkit.XRInteractionUpdateOrder.UpdatePhase) |
| PushPlaneLocalPosition() |
Returns the position of the front press plane of the button, using the overall selectionProgress of the button, which includes all forms of selection enabled on the interactable. |
| Reset() |
A Unity event function that is called when the script should reset it's default values |
| TryGetPressProgress(Single) |
Retrieves the 0..1 amount that the button is currently directly compressed by a finger. Returns true if at least one finger is actively pressing the button; false otherwise. |