Advertisement
dronkowitz

CGTheaterVideoPlayer.cs

Feb 7th, 2022 (edited)
1,225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.86 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.Video;
  5. public class CGTheaterVideoPlayer : MonoBehaviour
  6. {
  7.     public VideoPlayer videoPlayer;
  8.     private float timer;
  9.     // Start is called before the first frame update
  10.     void Start()
  11.     {
  12.         videoPlayer = GetComponent<VideoPlayer>();
  13.     }
  14.  
  15.     public void Setup(VideoClip clip)
  16.     {
  17.         videoPlayer.clip = clip;
  18.         timer = 0;
  19.         videoPlayer.Play();
  20.     }
  21.  
  22.     // Update is called once per frame
  23.     void Update()
  24.     {
  25.         if (Input.anyKeyDown)
  26.         {
  27.             gameObject.SetActive(false);
  28.         }
  29.         if (!videoPlayer.isPlaying)
  30.         {
  31.             timer += Time.deltaTime;
  32.             if (timer > 0.2f)
  33.             {
  34.                 gameObject.SetActive(false);
  35.             }
  36.         }
  37.     }
  38. }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement