UnityGameProjectsCode / InTheDarkGame / LoadNextLevel.cs
LoadNextLevel.cs
Raw
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class LoadNextLevel : MonoBehaviour
{
    public bool waitBeforeDetecting;
    public float waitTime;
    private float timeWaited;
    private bool waitDone;
    public GameObject continueText;

    private void Awake()
    {
        if (waitBeforeDetecting)
            continueText.SetActive(false);
    }

    private void Update()
    {
        if(waitBeforeDetecting && !waitDone)
        {
            timeWaited += Time.deltaTime;

            if (timeWaited >= waitTime)
            {
                continueText.SetActive(true);
                waitDone = true;
            }
            else
                return;
        }

        if(Input.anyKeyDown)
        {
            GameObject.Find("EventSystem").GetComponent<UICommands>().LoadLevel(SceneManager.GetActiveScene().buildIndex + 1);
        }
    }
}