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.UI;
- [RequireComponent(typeof(AudioSource))]
- public class Playvideo : MonoBehaviour {
- public CanvasGroup canvasX;
- public MovieTexture movie;
- private AudioSource audio;
- // Use this for initialization
- void Start () {
- GetComponent<RawImage> ().texture = movie as MovieTexture;
- audio = GetComponent<AudioSource> ();
- audio.clip = movie.audioClip;
- movie.Play ();
- audio.Play ();
- StartCoroutine(Example());
- }
- // Update is called once per frame
- void Update () {
- if (Input.GetKeyDown (KeyCode.Space) && movie.isPlaying)
- {
- movie.Pause ();
- }
- else if(Input.GetKeyDown (KeyCode.Space) && !movie.isPlaying)
- {
- movie.Play ();
- }
- }
- IEnumerator Example() {
- yield return new WaitForSeconds(movie.duration-0.5f);
- print(Time.time);
- movie.Pause ();
- canvasX.alpha = 0f;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement