26 lines
877 B
C#
26 lines
877 B
C#
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.XR.Interaction.Toolkit.UI;
|
|
using VRShopping.Interact;
|
|
|
|
public class CheckoutVRButton : MonoBehaviour, IPointerClickHandler
|
|
{
|
|
public void OnPointerClick(PointerEventData eventData)
|
|
{
|
|
GameObject whatWasClicked = eventData.pointerPress;
|
|
|
|
if (eventData is not TrackedDeviceEventData trackedData) return;
|
|
|
|
var interactorMB = trackedData.interactor as MonoBehaviour;
|
|
if (interactorMB == null) return;
|
|
GameObject whoClicked = interactorMB.gameObject;
|
|
|
|
PlayerController clickPlayer = whoClicked.GetComponentInParent<PlayerController>();
|
|
CheckoutMachine checkoutMachine = whatWasClicked.GetComponentInParent<CheckoutMachine>();
|
|
|
|
if (clickPlayer == null || checkoutMachine == null) return;
|
|
|
|
clickPlayer.Checkout(checkoutMachine);
|
|
}
|
|
}
|