colors | 用于接收像素数据的可选数组。 |
返回原始格式的像素数据。
这比调用 GetPixels
更快,因为像素数据不必转换为颜色结构,
如果需要对视频馈送进行连续处理,可能需要使用它。
您可以选择传入一个 Color32 数组在 colors
中使用,以免每帧都分配新内存,
从摄像机连续读取数据时,速度会更快。
数组需要初始化为与纹理宽度 * 高度一致的长度。如果不传递
数组,GetPixels32 将分配一个并将其返回。
using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour {
public WebCamTexture webcamTexture;
public Color32[] data;
void Start() {
webcamTexture = new WebCamTexture();
webcamTexture.Play();
data = new Color32[webcamTexture.width * webcamTexture.height];
}
void Update() {
webcamTexture.GetPixels32(data);
}
}