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

public class UIButtonClickLoad : MonoBehaviour
{
    public AudioSource audioSource;
    public string sceneToLoad;
    public float delayBeforeLoad = 0.25f;

    public void ClickAndLoad()
    {
        StartCoroutine(ClickRoutine());
    }

    private IEnumerator ClickRoutine()
    {
        if (audioSource != null)
        {
            audioSource.Play();
        }

        yield return new WaitForSeconds(delayBeforeLoad);

        SceneManager.LoadScene(sceneToLoad);
    }
}