Ok this should work but I dont know if its stopping on yield return or just hasn’t finished.
Im not getting debug 3 and my level is not loading the next scene. am i doing something wrong?
Using unity 5.4.0
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
public class SplashScreen : MonoBehaviour {
public float waitTimer;
public int levelIndex;
public KeyCode skipKey;
void Start() {
Debug.Log("1");
StartCoroutine(SplashWait());
}
void Update() {
if (Input.GetKey(skipKey)) {
StopAllCoroutines();
SceneManager.LoadScene(levelIndex);
}
}
IEnumerator SplashWait() {
Debug.Log("2");
yield return new WaitForSeconds(waitTimer);
Debug.Log("3");
SceneManager.LoadScene(levelIndex);
}
}