Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


StepForward()

Immediately advance the current time by one frame.
Read time 1 minuteLast updated 10 days ago

Definition

public void StepForward()

Remarks

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:
  • Analyze each frame of a video.
  • Debug issues related to the video or elements that play at certain frames.
  • Take finer control over the playback speed, because you can choose exactly when the next frame will appear. However, the WebGL implementation is unable to provide frame-accurate control due to platform limitations.

Examples

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(); } }}