using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using System.Collections;
using UnityEngine.Events;
[RequireComponent(typeof(AudioSource))]
public class VideoPlayer : MonoBehaviour
{
public string nextScene;
MovieTexture mt;
AudioSource As;
void Awake()
{
RawImage rim = GetComponent<RawImage>();
mt = (MovieTexture)rim.mainTexture;
AudioSource audioSource = GetComponent<AudioSource> ();
As = audioSource;
As.clip = mt.audioClip;
}
void Start(){
mt.Play();
As.Play ();
StartCoroutine (videoEnd(nextScene));
}
IEnumerator videoEnd(string scene){
while(mt.isPlaying){
yield return 0;
}
SceneManager.LoadScene(scene);
yield break;
}
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.