using System.Collections;
using UnityEngine;
using UnityEngine.UI;

public class Intro : MonoBehaviour 
{
	public string NextScene = "Menu";

	public MovieTexture movie;

	SceneController sceneController;

	void Start() 
	{
		GetComponent<RawImage>().texture = movie;
		movie.Play();

		StartCoroutine(HandleMovieEnd());
	}

	IEnumerator HandleMovieEnd()
	{
		sceneController = FindObjectOfType<SceneController>();
		
		while(movie.isPlaying)
		{
			yield return 0;
		}

		sceneController.FadeAndLoadScene(NextScene);
		
		yield break;
	}
}
