Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. using UnityEngine;
  2. using UnityEngine.Video;
  3.  
  4. public class VideoPlayerInput : MonoBehaviour
  5. {
  6. private VideoPlayer videoPlayer;
  7.  
  8. private void Awake()
  9. {
  10. videoPlayer = GetComponent<VideoPlayer>();
  11. videoPlayer.Prepare();
  12. }
  13.  
  14. private void Update()
  15. {
  16. if (Input.GetKeyDown(KeyCode.Space))
  17. {
  18. TogglePlay();
  19. }
  20. }
  21.  
  22. private void TogglePlay()
  23. {
  24. if (!videoPlayer.isPlaying)
  25. videoPlayer.Play();
  26. else
  27. videoPlayer.Pause();
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement