hi, i get a script which uses XRBaseInteractor.onSelectEntered which has been obsoleted and replaced with XRBaseInteractor.selectEntered
but when i replace
socketInteractor.onSelectEntered.AddListener(AddMagazine);
with
socketInteractor.selectEntered.AddListener(AddMagazine);
where AddMagazine is
public void AddMagazine(XRBaseInteractable interactable) {}
i get a compile error on the argument AddMagazine
the manual says Remarks onSelectEntered has been deprecated. Use selectEntered with updated signature instead. but i have no idea what the updated signature is
can anyone suggest how to fix this? thanks
ok i figured it out
void AddMagazine(SelectEnterEventArgs args)
{
Debug.Log("AddMagazine");
//magazine = args.interactableObject.GetComponent<Magazine>();
noOfBullets = 10;
source.PlayOneShot(reload);
}
void RemoveMagazine(SelectExitEventArgs args)
{
Debug.Log("RemoveMagazine");
//magazine = null;
noOfBullets = 0;
source.PlayOneShot(reload);
}
void Start()
{
socketInteractor.selectEntered.AddListener(AddMagazine);
socketInteractor.selectExited.AddListener(RemoveMagazine);
}
2 Likes
Hi,
Indeed : the deprecated event onSelectEntered is of type XRInteractorEvent, which calls a UnityEvent with an XRBaseInteractable as an argument. (here : Class XRBaseInteractor | XR Interaction Toolkit | 2.0.4 (unity3d.com))
The new event selectEntered is of type SelectEnterEvent, which calls a UnityEvent with a SelectEnterEventArgs as an argument. (here : Class XRBaseInteractor | XR Interaction Toolkit | 2.0.4 (unity3d.com))
You can find everything that you need regarding of Unity’s XR Interaction Toolkit here : Namespace UnityEngine.XR.Interaction.Toolkit | XR Interaction Toolkit | 2.0.4 (unity3d.com) (don’t forget to select the version that you’re using)