Created
April 24, 2017 23:07
-
-
Save unity3dcollege/5f7710702c0dcf18f7fd537893f99361 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEngine.Video; | |
public class VideoPlayerInput : MonoBehaviour | |
{ | |
private VideoPlayer videoPlayer; | |
private void Awake() | |
{ | |
videoPlayer = GetComponent<VideoPlayer>(); | |
videoPlayer.Prepare(); | |
} | |
private void Update() | |
{ | |
if (Input.GetKeyDown(KeyCode.Space)) | |
{ | |
TogglePlay(); | |
} | |
} | |
private void TogglePlay() | |
{ | |
if (!videoPlayer.isPlaying) | |
videoPlayer.Play(); | |
else | |
videoPlayer.Pause(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment