VideoPlayer.loopPointReached
Параметры
| Параметр | Описание |
|---|---|
| значение | Экземпляр VideoPlayer, который вызывает событие. |
Описание
VideoPlayer отправляет это событие, когда видео достигает конца своего проигрывания.
Если вы установите VideoPlayer.isLooping свойства true, это событие заставляет видео воспроизводиться снова. В противном случае VideoPlayer Вы также можете установить Петля свойства в Inspector окно VideoPlayer компонент.
Дополнительные ресурсы: VideoPlayer.isLooping, VideoPlayer.started, EventHandler.
// This script plays a Particle System when the video finishes, and then loops the video. // Attach this script and a VideoPlayer component to a GameObject. Also attach a ParticleSystem in the Inspector.
using UnityEngine; using UnityEngine.Video;
public class LoopPointReachedExample : MonoBehaviour { VideoPlayer videoPlayer; public ParticleSystem particles;
void Start() { videoPlayer = GetComponent<VideoPlayer>(); particles.playOnAwake = false;
// When the video playback is done, restart the video. videoPlayer.isLooping = true;
// Each time the video reaches the end, call this function. videoPlayer.loopPointReached += OnLoopPointReached;
videoPlayer.Play(); }
void OnLoopPointReached(VideoPlayer vp) { // Play the particle effect when the video reaches the end. Debug.Log("Loop finished, play particle effect."); particles.Play(); } }