Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5.  
  6. [RequireComponent(typeof(AudioSource))]
  7.  
  8. public class Playvideo : MonoBehaviour {
  9.  
  10.  
  11. public CanvasGroup canvasX;
  12. public MovieTexture movie;
  13. private AudioSource audio;
  14.  
  15. // Use this for initialization
  16. void Start () {
  17.  
  18.  
  19. GetComponent<RawImage> ().texture = movie as MovieTexture;
  20. audio = GetComponent<AudioSource> ();
  21. audio.clip = movie.audioClip;
  22. movie.Play ();
  23. audio.Play ();
  24. StartCoroutine(Example());
  25.  
  26.  
  27.  
  28. }
  29.  
  30. // Update is called once per frame
  31. void Update () {
  32. if (Input.GetKeyDown (KeyCode.Space) && movie.isPlaying)
  33. {
  34. movie.Pause ();
  35. }
  36. else if(Input.GetKeyDown (KeyCode.Space) && !movie.isPlaying)
  37. {
  38. movie.Play ();
  39. }
  40.  
  41.  
  42.  
  43.  
  44. }
  45.  
  46.  
  47. IEnumerator Example() {
  48.  
  49. yield return new WaitForSeconds(movie.duration-0.5f);
  50. print(Time.time);
  51. movie.Pause ();
  52.  
  53. canvasX.alpha = 0f;
  54.  
  55.  
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement