using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;

public class SceneLoad : MonoBehaviour
{
    public float DelayInSeconds = 0;
    public string NextScene;

    private void Awake()
    {
        if (DelayInSeconds > 0)        
            StartCoroutine(LoadAfterDelay(DelayInSeconds));
    }

    void Update ()
	{
        if (Input.anyKeyDown && NextScene != null)
            Load();
	}

    public void Load()
    {
        SceneManager.LoadScene(NextScene);
    }

    private IEnumerator LoadAfterDelay(float seconds)
    {
        yield return new WaitForSeconds(seconds);
        Load();
    }
}
