Immediately advance the current time by one frame.
If the video is currently playing, this method will pause the video before it advances to the next frame. However, if the VideoPlayer isn't prepared, this method will trigger preparation and display the first frame, but will not skip to the next frame. It steps forward from non-initialized to frame 0.
This method is useful if you want to:
using UnityEngine; using UnityEngine.Video; using System.Collections;
// In the Inspector of your GameObject, attach this script and a VideoPlayer component. // Also, assign a VideoClip to your VideoPlayer component. // Use this script to cycle through a video frame by frame.
public class StepForwardExample : MonoBehaviour { VideoPlayer videoPlayer;
public void Start() { videoPlayer = GetComponent<VideoPlayer>(); videoPlayer.Pause(); }
private void Update() { if (Input.GetKeyDown("space") && videoPlayer.isPrepared) { Debug.Log("Space key pressed."); // Go forward one frame in the video when you press the Spacebar. videoPlayer.StepForward(); } } }