docs.unity.cn

XR Interaction Toolkit 2.4.1

    Show / Hide Table of Contents

    Class XRBaseController

    Interprets feature values on a tracked input controller device into XR Interaction states, such as Select. Additionally, it applies the current pose value of a tracked device to the transform of the GameObject.

    Inheritance
    Object
    Object
    Component
    Behaviour
    MonoBehaviour
    XRBaseController
    ActionBasedController
    XRController
    XRScreenSpaceController
    Inherited Members
    MonoBehaviour.IsInvoking()
    MonoBehaviour.CancelInvoke()
    MonoBehaviour.Invoke(String, Single)
    MonoBehaviour.InvokeRepeating(String, Single, Single)
    MonoBehaviour.CancelInvoke(String)
    MonoBehaviour.IsInvoking(String)
    MonoBehaviour.StartCoroutine(String)
    MonoBehaviour.StartCoroutine(String, Object)
    MonoBehaviour.StartCoroutine(IEnumerator)
    MonoBehaviour.StopCoroutine(IEnumerator)
    MonoBehaviour.StopCoroutine(Coroutine)
    MonoBehaviour.StopCoroutine(String)
    MonoBehaviour.StopAllCoroutines()
    MonoBehaviour.print(Object)
    MonoBehaviour.useGUILayout
    MonoBehaviour.runInEditMode
    Behaviour.enabled
    Behaviour.isActiveAndEnabled
    Component.GetComponent(Type)
    Component.GetComponent<T>()
    Component.TryGetComponent(Type, Component)
    Component.TryGetComponent<T>(T)
    Component.GetComponent(String)
    Component.GetComponentInChildren(Type, Boolean)
    Component.GetComponentInChildren(Type)
    Component.GetComponentInChildren<T>(Boolean)
    Component.GetComponentInChildren<T>()
    Component.GetComponentsInChildren(Type, Boolean)
    Component.GetComponentsInChildren(Type)
    Component.GetComponentsInChildren<T>(Boolean)
    Component.GetComponentsInChildren<T>(Boolean, List<T>)
    Component.GetComponentsInChildren<T>()
    Component.GetComponentsInChildren<T>(List<T>)
    Component.GetComponentInParent(Type, Boolean)
    Component.GetComponentInParent(Type)
    UnityEngine.Component.GetComponentInParent<T>(System.Boolean)
    Component.GetComponentInParent<T>()
    Component.GetComponentsInParent(Type, Boolean)
    Component.GetComponentsInParent(Type)
    Component.GetComponentsInParent<T>(Boolean)
    Component.GetComponentsInParent<T>(Boolean, List<T>)
    Component.GetComponentsInParent<T>()
    Component.GetComponents(Type)
    Component.GetComponents(Type, List<Component>)
    Component.GetComponents<T>(List<T>)
    Component.GetComponents<T>()
    Component.CompareTag(String)
    Component.SendMessageUpwards(String, Object, SendMessageOptions)
    Component.SendMessageUpwards(String, Object)
    Component.SendMessageUpwards(String)
    Component.SendMessageUpwards(String, SendMessageOptions)
    Component.SendMessage(String, Object)
    Component.SendMessage(String)
    Component.SendMessage(String, Object, SendMessageOptions)
    Component.SendMessage(String, SendMessageOptions)
    Component.BroadcastMessage(String, Object, SendMessageOptions)
    Component.BroadcastMessage(String, Object)
    Component.BroadcastMessage(String)
    Component.BroadcastMessage(String, SendMessageOptions)
    Component.transform
    Component.gameObject
    Component.tag
    Object.GetInstanceID()
    Object.GetHashCode()
    Object.Equals(Object)
    Object.Instantiate(Object, Vector3, Quaternion)
    Object.Instantiate(Object, Vector3, Quaternion, Transform)
    Object.Instantiate(Object)
    Object.Instantiate(Object, Transform)
    Object.Instantiate(Object, Transform, Boolean)
    Object.Instantiate<T>(T)
    Object.Instantiate<T>(T, Vector3, Quaternion)
    Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
    Object.Instantiate<T>(T, Transform)
    Object.Instantiate<T>(T, Transform, Boolean)
    Object.Destroy(Object, Single)
    Object.Destroy(Object)
    Object.DestroyImmediate(Object, Boolean)
    Object.DestroyImmediate(Object)
    Object.FindObjectsOfType(Type)
    Object.FindObjectsOfType(Type, Boolean)
    Object.FindObjectsByType(Type, FindObjectsSortMode)
    Object.FindObjectsByType(Type, FindObjectsInactive, FindObjectsSortMode)
    Object.DontDestroyOnLoad(Object)
    Object.FindObjectsOfType<T>()
    UnityEngine.Object.FindObjectsByType<T>(UnityEngine.FindObjectsSortMode)
    UnityEngine.Object.FindObjectsOfType<T>(System.Boolean)
    UnityEngine.Object.FindObjectsByType<T>(UnityEngine.FindObjectsInactive, UnityEngine.FindObjectsSortMode)
    Object.FindObjectOfType<T>()
    UnityEngine.Object.FindObjectOfType<T>(System.Boolean)
    UnityEngine.Object.FindFirstObjectByType<T>()
    UnityEngine.Object.FindAnyObjectByType<T>()
    UnityEngine.Object.FindFirstObjectByType<T>(UnityEngine.FindObjectsInactive)
    UnityEngine.Object.FindAnyObjectByType<T>(UnityEngine.FindObjectsInactive)
    Object.FindObjectOfType(Type)
    Object.FindFirstObjectByType(Type)
    Object.FindAnyObjectByType(Type)
    Object.FindObjectOfType(Type, Boolean)
    Object.FindFirstObjectByType(Type, FindObjectsInactive)
    Object.FindAnyObjectByType(Type, FindObjectsInactive)
    Object.ToString()
    Object.name
    Object.hideFlags
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: UnityEngine.XR.Interaction.Toolkit
    Syntax
    [DefaultExecutionOrder(-29990)]
    [DisallowMultipleComponent]
    public abstract class XRBaseController : MonoBehaviour

    Properties

    activateInteractionState

    (Read Only) The current activate interaction state.

    Declaration
    public InteractionState activateInteractionState { get; }
    Property Value
    Type Description
    InteractionState

    animateModel

    Whether to animate the model in response to interaction events. When enabled, the animation trigger will be set for the corresponding animator component on the controller model when a select or deselect interaction events occurs.

    Declaration
    public bool animateModel { get; set; }
    Property Value
    Type Description
    Boolean
    See Also
    modelSelectTransition
    modelDeSelectTransition

    currentControllerState

    The current state of the controller.

    Declaration
    public XRControllerState currentControllerState { get; set; }
    Property Value
    Type Description
    XRControllerState

    enableInputActions

    Whether input for XR Interaction events is enabled for this controller. When enabled, Unity reads the current input of the controller device each frame.

    Declaration
    public bool enableInputActions { get; set; }
    Property Value
    Type Description
    Boolean
    Remarks

    You can disable this in order to drive the controller state manually instead of from reading current inputs, such as when playing back recorded inputs.

    See Also
    enableInputTracking

    enableInputTracking

    Whether input pose tracking is enabled for this controller. When enabled, Unity reads the current tracking pose input of the controller device each frame.

    Declaration
    public bool enableInputTracking { get; set; }
    Property Value
    Type Description
    Boolean
    Remarks

    You can disable this in order to drive the controller state manually instead of from reading current inputs, such as when playing back recorded pose inputs.

    See Also
    enableInputActions

    hideControllerModel

    Whether to hide the controller model.

    Declaration
    public bool hideControllerModel { get; set; }
    Property Value
    Type Description
    Boolean
    See Also
    model
    hideControllerOnSelect

    model

    The instance of the controller model in the scene. You can set this to an existing object instead of using modelPrefab.

    Declaration
    public Transform model { get; set; }
    Property Value
    Type Description
    Transform
    Remarks

    If set, it should reference a child GameObject of this behavior so it will update with the controller pose.

    modelDeSelectTransition

    The animation trigger name to activate upon deselecting.

    Declaration
    public string modelDeSelectTransition { get; set; }
    Property Value
    Type Description
    String
    See Also
    SetTrigger

    modelParent

    The transform that this behavior uses as the parent for the model prefab when it is instantiated.

    Declaration
    public Transform modelParent { get; set; }
    Property Value
    Type Description
    Transform
    Remarks

    Automatically instantiated and set in Awake() if not already set. Setting this will not automatically destroy the previous object.

    modelPrefab

    The prefab of a controller model to show for this controller that this behavior automatically instantiates.

    Declaration
    public Transform modelPrefab { get; set; }
    Property Value
    Type Description
    Transform
    Remarks

    This behavior automatically instantiates an instance of the prefab as a child of modelParent upon startup unless model is already set, in which case this value is ignored.

    See Also
    model

    modelSelectTransition

    The animation trigger name to activate upon selecting.

    Declaration
    public string modelSelectTransition { get; set; }
    Property Value
    Type Description
    String
    See Also
    SetTrigger

    selectInteractionState

    (Read Only) The current select interaction state.

    Declaration
    public InteractionState selectInteractionState { get; }
    Property Value
    Type Description
    InteractionState

    uiPressInteractionState

    (Read Only) The current UI press interaction state.

    Declaration
    public InteractionState uiPressInteractionState { get; }
    Property Value
    Type Description
    InteractionState

    uiScrollValue

    (Read Only) The current UI scroll value.

    Declaration
    public Vector2 uiScrollValue { get; }
    Property Value
    Type Description
    Vector2

    updateTrackingType

    The time within the frame that the controller samples tracking input.

    Declaration
    public XRBaseController.UpdateType updateTrackingType { get; set; }
    Property Value
    Type Description
    XRBaseController.UpdateType
    See Also
    XRBaseController.UpdateType

    Methods

    ApplyControllerState(XRInteractionUpdateOrder.UpdatePhase, XRControllerState)

    Applies the given controller state to this XRBaseController. Depending on the update phase, the XR Interaction states may be copied and/or the pose value may be applied to the transform of the GameObject. Unity calls this automatically from FixedUpdate(), OnBeforeRender(), and UpdateController().

    Declaration
    protected virtual void ApplyControllerState(XRInteractionUpdateOrder.UpdatePhase updatePhase, XRControllerState controllerState)
    Parameters
    Type Name Description
    XRInteractionUpdateOrder.UpdatePhase updatePhase

    The update phase during this call.

    XRControllerState controllerState

    The state of the controller to apply.

    Awake()

    See MonoBehaviour.

    Declaration
    protected virtual void Awake()

    FixedUpdate()

    Corresponds to FixedUpdate(). It has the frequency of the physics system and is called every fixed framerate frame.

    Declaration
    protected virtual void FixedUpdate()

    GetModelPrefab()

    Gets the prefab that should be instantiated upon startup.

    Declaration
    protected virtual GameObject GetModelPrefab()
    Returns
    Type Description
    GameObject

    Returns the prefab that should be instantiated upon startup.

    OnBeforeRender()

    This method is automatically called for "Just Before Render" input updates for VR devices.

    Declaration
    protected virtual void OnBeforeRender()
    See Also
    UnityEngine.Application.onBeforeRender

    OnDisable()

    See MonoBehaviour.

    Declaration
    protected virtual void OnDisable()

    OnEnable()

    See MonoBehaviour.

    Declaration
    protected virtual void OnEnable()

    SendHapticImpulse(Single, Single)

    Play a haptic impulse on the controller if one is available.

    Declaration
    public virtual bool SendHapticImpulse(float amplitude, float duration)
    Parameters
    Type Name Description
    Single amplitude

    Amplitude (from 0.0 to 1.0) to play impulse at.

    Single duration

    Duration (in seconds) to play haptic impulse.

    Returns
    Type Description
    Boolean

    Returns true if successful. Otherwise, returns false.

    Update()

    See MonoBehaviour.

    Declaration
    protected void Update()

    UpdateController()

    Updates the controller every frame. This is called automatically from Update().

    Declaration
    protected virtual void UpdateController()

    UpdateControllerModelAnimation()

    Updates the animation on the model instance (if the model contains an Animator). Unity calls this automatically from UpdateController().

    Declaration
    protected virtual void UpdateControllerModelAnimation()
    See Also
    animateModel
    modelSelectTransition
    modelDeSelectTransition

    UpdateInput(XRControllerState)

    Updates the XR Interaction states in the given controller state based on the current inputs of the controller device. Unity calls this automatically during UpdateController() so explicit calls to this function are not required.

    Declaration
    protected virtual void UpdateInput(XRControllerState controllerState)
    Parameters
    Type Name Description
    XRControllerState controllerState

    The state of the controller.

    UpdateTrackingInput(XRControllerState)

    Updates the pose values in the given controller state based on the current tracking input of the controller device. Unity calls this automatically from FixedUpdate(), OnBeforeRender(), and UpdateController() so explicit calls to this function are not required.

    Declaration
    protected virtual void UpdateTrackingInput(XRControllerState controllerState)
    Parameters
    Type Name Description
    XRControllerState controllerState

    The state of the controller.

    See Also

    ActionBasedController
    In This Article
    • Properties
      • activateInteractionState
      • animateModel
      • currentControllerState
      • enableInputActions
      • enableInputTracking
      • hideControllerModel
      • model
      • modelDeSelectTransition
      • modelParent
      • modelPrefab
      • modelSelectTransition
      • selectInteractionState
      • uiPressInteractionState
      • uiScrollValue
      • updateTrackingType
    • Methods
      • ApplyControllerState(XRInteractionUpdateOrder.UpdatePhase, XRControllerState)
      • Awake()
      • FixedUpdate()
      • GetModelPrefab()
      • OnBeforeRender()
      • OnDisable()
      • OnEnable()
      • SendHapticImpulse(Single, Single)
      • Update()
      • UpdateController()
      • UpdateControllerModelAnimation()
      • UpdateInput(XRControllerState)
      • UpdateTrackingInput(XRControllerState)
    • See Also
    Back to top Copyright © 2023 Unity Technologies — Terms of use
    Generated by DocFX
    on Tuesday, July 18, 2023