Skip to content

Instantly share code, notes, and snippets.

@unity3dcollege
Created April 24, 2017 23:07
Show Gist options
  • Save unity3dcollege/5f7710702c0dcf18f7fd537893f99361 to your computer and use it in GitHub Desktop.
Save unity3dcollege/5f7710702c0dcf18f7fd537893f99361 to your computer and use it in GitHub Desktop.
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