Ok so i have a rawImage and this script is within it
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class PlayVideo : MonoBehaviour
{
public MovieTexture movie;
RawImage rawImageComp;
AudioSource audioS;
// Use this for initialization
void Start()
{
rawImageComp = GetComponent<RawImage>();
audioS = GetComponent<AudioSource>();
PlayClip();
}
void PlayClip()
{
audioS.clip = movie.audioClip;
audioS.Play();
rawImageComp.texture = movie;
movie.Play();
}
}
I don’t know how to do a wait until the movie ends and move to the next scene, if you know how, please be sure to re-write how to do this, i am a visual learner.
Add a check if it is still playing in the Update() function:
public MovieTexture movie;
RawImage rawImageComp;
AudioSource audioS;
private bool movieStarted;
// Use this for initialization
void Start()
{
rawImageComp = GetComponent<RawImage>();
audioS = GetComponent<AudioSource>();
PlayClip();
}
void PlayClip() {
audioS.clip = movie.audioClip;
audioS.Play();
rawImageComp.texture = movie;
movie.Play();
movieStarted = true; // paranoia, only necessary if Update() is called before this one
}
void Update() {
if (movieStarted && !movie.isPlaying) {
movieStarted = false; // avoid getting here after the scene change was triggered, because it might be done asynchronously
// Do something great here, probably this:
SceneManager.LoadScene("TheSceneAfterTheMovie");
}
}