Game Designer
{
void Start()
{
var videoPlayer = gameObject.GetComponent<VideoPlayer>();
videoPlayer.Prepare();
}
void Update()
{
var videoPlayer = gameObject.GetComponent<VideoPlayer>();
if (videoPlayer.isPrepared) {
if(Input.GetKeyDown(KeyCode.UpArrow) || (Input.GetKeyDown(KeyCode.W))
{
startVideo();
}
else if (Input.GetKeyUp(KeyCode.UpArrow) || (Input.GetKeyUp(KeyCode.W))
{
stopVideo();
}
}
}
void startVideo()
{
var videoPlayer = gameObject.GetComponent<VideoPlayer>();
videoPlayer.Play();
videoPlayer.loopPointReached += EndReached;
}
void stopVideo()
{
var videoPlayer = gameObject.GetComponent<VideoPlayer>();
videoPlayer.Pause();
}
void EndReached(VideoPlayer videoPlayer)
{
SceneManager.LoadScene("credits");
}
}