- Home /
This post has been wikified, any user with enough reputation can edit it.
Question by
Harardin · Aug 21, 2015 at 09:13 AM ·
c#scriptingbasicsloadlevel
Application.LoadLevel problem.
Hello everyone I have a small problem. I have an empty scene where just main camera what should play one sound and then load in to the next scene, I made a Coroutine but something just got wrong. Does anyone have idea where I made a mistake? Here is a script what attached to the camera.
public class RelayScriptGo : MonoBehaviour {
public Camera MainCam;
public AudioSource source;
public AudioClip clip;
void Start ()
{
source = GetComponent<AudioSource>();
MainCam = GetComponent<Camera>();
LoadFirstChapter();
}
public IEnumerator LoadFirstChapter()
{
source.PlayOneShot(clip);
yield return new WaitForSeconds(3);
Application.LoadLevel("chapter1sceen");
Debug.Log("working");
}
}
Comment
Best Answer
Wiki
Answer by Harardin · Aug 21, 2015 at 09:20 AM
So sorry for creating this. Just miss this part in the start StartCoroutine(LoadFirstChapter());
public class RelayScriptGo : MonoBehaviour {
public Camera MainCam;
public AudioSource source;
public AudioClip clip;
void Start ()
{
source = GetComponent<AudioSource>();
MainCam = GetComponent<Camera>();
StartCoroutine(LoadFirstChapter());
}
public IEnumerator LoadFirstChapter()
{
source.PlayOneShot(clip);
yield return new WaitForSeconds(3);
Application.LoadLevel(2);
Debug.Log("working");
}
}