Hi guys
Still trying to get to grips with C# and im still not very good, im trying to have a sound play when a gui button is pressed before the loadlevel is executed. I’ve done the research and im still not getting it. So far the sound doesnt play and the level doesnt load either. I somehow got it to play the sound but the level didnt load. - here’s what i got so far:
public class levelSelector : MonoBehaviour
{
public Texture levelOne;
public Texture levelTwo;
public Texture levelThree;
public GUIStyle GuiSlot;
IEnumerator playSoundThenLoad()
{
audio.Play();
yield return new WaitForSeconds(2);
Application.LoadLevel("level 1");
}
void OnGUI () {
if(GUI.Button(new Rect(270,110,300,100), levelOne, GuiSlot))
playSoundThenLoad(); // Problem here
}