Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.SceneManagement;
- using UnityEngine.Video;
- public class CGTheater : MonoBehaviour
- {
- public static string currentvid;
- public static string nextscene;
- public List<VideoClip> Videos = new List<VideoClip>();
- // Start is called before the first frame update
- void Start()
- {
- StartCoroutine(PlayVideo());
- }
- // Update is called once per frame
- void Update()
- {
- }
- public IEnumerator PlayVideo()
- {
- foreach (VideoClip v in Videos)
- {
- if (v.name == currentvid)
- {
- GetComponent<VideoPlayer>().clip = v;
- }
- }
- GetComponent<VideoPlayer>().Play();
- //the video may be running in 30 Frames per second. So if a video is 10 seconds long the frame count will be 300.
- //if the computer is running at 60 fps, than the video would end half way through because the computer counted to 300 in half the time
- VideoPlayer vp = GetComponent<VideoPlayer>();
- string i = GetComponent<VideoPlayer>().frameCount.ToString();
- int frames = int.Parse(i);
- float currenttime = 0;
- float finaltime = ((float)vp.length);
- while (currenttime < finaltime)
- {
- yield return new WaitForSeconds(Time.deltaTime);
- currenttime += Time.deltaTime;
- if (Input.GetKeyDown(KeyCode.Escape))
- {
- break;
- }
- }
- SceneManager.LoadScene("CG Theater");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement