Perhaps my code is wrong, but I cannot seem to figure out how to stop the darn audio. It worked fine in Unity iPhone. The music is playing, when I say audio.Stop it should stop. This does not happen.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class SoundManager : MonoBehaviour
{
public AudioClip ReelStopSoundStandard;
public AudioClip ReelSpinMusic1;
public AudioClip ReelSpinMusic2;
public AudioClip ReelSpinMusic3;
public AudioClip SpinButton;
int reelSpinMusicCounter = 1;
public void PlayReelStopStandard()
{
audio.PlayOneShot(ReelStopSoundStandard);
}
public void PlaySpinButton()
{
audio.PlayOneShot(SpinButton);
}
public void StopMusic()
{
audio.Stop();
}
public void PlayReelSpinMusic()
{
switch(reelSpinMusicCounter)
{
case 1:
audio.PlayOneShot(ReelSpinMusic1);
break;
case 2:
audio.PlayOneShot(ReelSpinMusic2);
break;
case 3:
audio.PlayOneShot(ReelSpinMusic3);
break;
}
reelSpinMusicCounter++;
if (reelSpinMusicCounter == 4)
reelSpinMusicCounter = 1;
}
}
I have also tried:
audio.Clip = ReelSpinMusic1;
audio.Play();
But it still will not stop. audio.Pause won’t work either.
I have a SoundManager script on a gameobject. I have an audio source for each clip on the object and the sound file is dragged onto the public variable slot for each variable in this script.