Version: 5.3 (switch to 5.4b)
IdiomaEnglish
  • C#
  • JS

Idioma de script

Selecciona tu lenguaje de programación favorito. Todos los fragmentos de código serán mostrados en este lenguaje.

WebCamTexture.GetPixels32

Sugiere un cambio

¡Éxito!

Gracias por ayudarnos a mejorar la calidad de la documentación de Unity. A pesar de que no podemos aceptar todas las sugerencias, leemos cada cambio propuesto por nuestros usuarios y actualizaremos los que sean aplicables.

Cerrar

No se puedo enviar

Por alguna razón su cambio sugerido no pudo ser enviado. Por favor <a>intente nuevamente</a> en unos minutos. Gracias por tomarse un tiempo para ayudarnos a mejorar la calidad de la documentación de Unity.

Cerrar

Cancelar

Cambiar al Manual
public function GetPixels32(colors: Color32[] = null): Color32[];
public Color32[] GetPixels32(Color32[] colors = null);
public function GetPixels32(colors: Color32[] = null): Color32[];
public Color32[] GetPixels32(Color32[] colors = null);

Parámetros

colors Optional array to receive pixel data.

Descripción

Returns the pixels data in raw format.

This can be faster then calling GetPixels, as pixel data does not have to be converted to color structs, so you may want to use it if you need to do continuous processing on the video feed. You can optionally pass in an array of Color32s to use in colors to avoid allocating new memory each frame, which is faster when you are continuously reading data from the camera. The array needs to be initialized to a length matching width * height of the texture. If you don't pass an array, GetPixels32 will allocate one for you and return it.

	var webcamTexture : WebCamTexture;
	var data : Color32[];
	
	function Start () {
		// Start web cam feed
		webcamTexture = WebCamTexture();
		webcamTexture.Play();
		data = new Color32[webcamTexture.width * webcamTexture.height];
	}
	
	function Update () {
		webcamTexture.GetPixels32 (data);
		// Do processing of data here.
	}
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); } }