UP-Viagg-io/Viagg-io/Assets/Scripts/Audio/OnGrabSound.cs

27 lines
678 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR.Interaction.Toolkit;
using FMODUnity;
[RequireComponent(typeof(XRGrabInteractable))]
public class OnGrabSound : MonoBehaviour
{
[SerializeField]
EventReference soundRef;
// Start is called before the first frame update
void Start()
{
if (GetComponent<XRGrabInteractable>())
{
GetComponent<XRGrabInteractable>().selectEntered.AddListener(SelectEnterEventHandler);
}
}
private void SelectEnterEventHandler(SelectEnterEventArgs args)
{
RuntimeManager.PlayOneShot(soundRef, transform.position);
}
}