I have tried many examples. I’ve even tried scripting the sounds without any Empty Gameobjects and dynamically creating on. My last resort was to create 3 gameobjects with 1 of 3 sounds attached to them and calling the play method and I was still unable to get them to play. Any advice would be greatful.
void OnGUI()
{
Debug.Log(introPortion);
if(introPortion == 0)
{
GUI.DrawTexture(new Rect(0,0,1024,768),introAnimation1[curRate]);
if(curRate == 9)
{
GameObject go = GameObject.Find("AudioObject1");
AudioSource source = go.GetComponent<AudioSource>();
StreamReader reader = new StreamReader("Assets/Resources/Text Files/introText1.txt");
string fileContent;
fileContent = reader.ReadToEnd();
reader.Close();
GUI.Label(new Rect(7,Screen.height - 200,Screen.width - 14,175),fileContent,CustomStyle);
//Debug.Log(GameObject.Find("Main Camera").GetComponent<AudioSource>().clip.length);
StartCoroutine(Pause(source.clip.length,source));
}
}
if(introPortion == 1)
{
GUI.DrawTexture(new Rect(0,0,1024,768),introAnimation1[curRate]);
if(curRate == 43)
{
GameObject go = GameObject.Find("AudioObject2");
AudioSource source = go.GetComponent<AudioSource>();
StreamReader reader = new StreamReader("Assets/Resources/Text Files/introText2.txt");
string fileContent;
fileContent = reader.ReadToEnd();
reader.Close();
GUI.Label(new Rect(7,Screen.height - 200,Screen.width - 14,175),fileContent,CustomStyle);
StartCoroutine(Pause(30.0f,source));
}
}
if(introPortion == 2)
{
GUI.DrawTexture(new Rect(0,0,1024,768),introAnimation1[curRate]);
GUI.DrawTexture(new Rect(0,0,characterPorts[0].width/3,characterPorts[0].height/3),characterPorts[0]);
GUI.DrawTexture(new Rect((Screen.width - (characterPorts[1].width/2)+120),0,characterPorts[1].width/3,characterPorts[1].height/3),characterPorts[1]);
if(curRate == 77)
{
GameObject go = GameObject.Find("AudioObject3");
AudioSource source = go.GetComponent<AudioSource>();
source.rolloffMode = 0;
source.volume = 100.0f;
StreamReader reader = new StreamReader("Assets/Resources/Text Files/introText3.txt");
string fileContent;
fileContent = reader.ReadToEnd();
reader.Close();
GUI.Label(new Rect(7,Screen.height - 200,Screen.width - 14,175),fileContent,CustomStyle);
if(GUI.Button(new Rect(Screen.width - 130,Screen.height - 40,128,30),"Next"))
{
Application.LoadLevel("newGameScene");
}
}
}
}
IEnumerator Pause(float waitTime, AudioSource go)
{
go.Play();
Debug.Log("Paused");
yield return new WaitForSeconds(waitTime);
Debug.Log("Not Paused");
if(introPortion < 2)
{
introPortion += 1;
StopAllCoroutines();
}
else
introPortion = 2;
}
Lazerath