33 lines
707 B
C#
33 lines
707 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class ColliderPlay : MonoBehaviour
|
|
{
|
|
|
|
public bool isRepeat = true;
|
|
bool isCanPlay = true;
|
|
AudioSource source;
|
|
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
source = GetComponent<AudioSource>();
|
|
}
|
|
|
|
private void OnTriggerEnter(Collider other)
|
|
{
|
|
if (other.gameObject.name == "XROriginHands" || other.gameObject.name == "Main Camera")
|
|
{
|
|
if (!isCanPlay) return;
|
|
if (source != null)
|
|
source.Play();
|
|
if (!isRepeat)
|
|
{
|
|
isCanPlay = false;
|
|
}
|
|
}
|
|
}
|
|
}
|