Open Slithersy opened 2 years ago
Have you even read the documentation or tried the examples?
You can easily get both the "interactor" and "interactable" through every event fired by the interactors and interactables.
Take a look at the most basic of event arguments, the SelectEnterEventArgs.
Here you can access both the interactableObject
and interactorObject
. This applies for all other events also (hover, select, activate, deactivate).
To write it out in the simplest sample for you:
using UnityEngine;
using UnityEngine.XR.Interaction.Toolkit;
[RequireComponent(typeof(XRGrabInteractable))]
public class InteractorInteractableFinder : MonoBehaviour
{
XRBaseInteractable m_Interactable;
void OnEnable()
{
m_Interactable = GetComponent<XRBaseInteractable>();
m_Interactable.firstSelectEntered.AddListener(OnFirstSelectEntered);
}
void OnDisable()
{
m_Interactable.firstSelectEntered.RemoveListener(OnFirstSelectEntered);
}
protected virtual void OnFirstSelectEntered(SelectEnterEventArgs args)
{
var interactor = args.interactorObject;
var interactable = args.interactableObject;
Debug.Log($"{interactor} selected/grabbed {interactable}.")
}
}
Properly using the Interaction Toolkit does not require any extra raycast implementations at all.
Hello! I have noticed the XR Interaction Toolkit does not offer the most basic form of customization, actually being to adjust/know which object you are grabbing. This poses a massive issue where I MUST use a more expensive method such as raycast on update even though XR Interaction Toolkit is already raycasting to make it work properly, and even then it will not be fully reliable for certain actions.
I need to differentiate between a button and an interactable. To save on performance, I have decided to use the already built-in raycasting system that provides grabbing. Small issue, we have no access to this system. So what? Are we just gonna have to code either our own grabbing system from scratch or use unreliable methods? This defeats the whole purpose. Please do something about this.