OK This is going to sound a bit confusing so please bear with my while I try and explain.
OK lets say I have a scene we’ll call it scene one for simplicity. In this scene I have a UI panel with buttons that I want to play a sound clip with.
Now here comes the possible confusing part.
However I want to play the sounds that my buttons select in scene one on a game object located in scene two. So that when you select a sound in scene one, scene two will load and play that sound on my game object. So far in scene 2 I have this script that when a sound is done playing the scene one will automatically load back up so that another sound can be clicked and then played.
I hope I explained that right.
This is the script I have in scene two, scene one is currently just buttons with sound selections.
using UnityEngine;
using System.Collections;
public class WaveformAudioManager : MonoBehaviour {
//Exit Waveform Screen after audio has finished playing to Main Logo screen
void Start()
{
audio.Play();
StartCoroutine(LoadAfterDelay1("KnightSpinningLogo_NoKITTintro"));
}
IEnumerator LoadAfterDelay1(string levelName){
//yield return new WaitForSeconds(2.5f); // wait 1 seconds
yield return new WaitForSeconds(audio.clip.length); //Waits till Audio is done playing
Application.LoadLevel(levelName);
}
}