I have the following situation. I am reading a pattern with RA with vuforia . At the moment of reading the pattern, it begins to play a sound while I am reading but if I stop reading the pattern the sound stops. My question is the following there is some way that once the sound begins to play does not stop until it reaches the end. Then I leave the code.
using UnityEngine;
using Vuforia;
public class reproduccionAudio : MonoBehaviour, ITrackableEventHandler
{
private TrackableBehaviour mTrackableBehaviour;
void Start(){
mTrackableBehaviour = GetComponent<TrackableBehaviour>();
if (mTrackableBehaviour){
mTrackableBehaviour.RegisterTrackableEventHandler(this);
}
}
public void OnTrackableStateChanged( TrackableBehaviour.Status previousStatus, TrackableBehaviour.Status newStatus){
if (newStatus == TrackableBehaviour.Status.DETECTED ||
newStatus == TrackableBehaviour.Status.TRACKED ||
newStatus == TrackableBehaviour.Status.EXTENDED_TRACKED )
{
GetComponent<AudioSource>().Play();
}else{
GetComponent<AudioSource>().Stop();
}
}
}
Thanks