WebCamTexture.didUpdateThisFrame

切换到手册
public bool didUpdateThisFrame ;

描述

视频缓冲区是否更新了此帧?

使用此属性可检查视频缓冲区自上帧以来是否发生了更改。设置低帧率时, 视频更新速度可能比游戏更慢。因为在每次 Update 调用中执行高开销的视频 处理没有意义,请在进行任意处理前检查此值。

using UnityEngine;

public class ExampleScript : MonoBehaviour { WebCamTexture webcamTexture; Color32[] data;

void Start() { // Start web cam feed webcamTexture = new WebCamTexture(); webcamTexture.Play(); data = new Color32[webcamTexture.width * webcamTexture.height]; }

void Update() { if (webcamTexture.didUpdateThisFrame) { webcamTexture.GetPixels32(data); // Do processing of data here. } } }