How to get pixels from an external texture?


I wanted to know how to get pixels from an external texture (plugin : EasyMovieTexture).

Currently, I’m using this function :

private Texture2D GetReadableTexture(Texture2D tex)
	if (myTexture2D == null)
		myTexture2D = new Texture2D(tex.width, tex.height);

	RenderTexture tmp = RenderTexture.GetTemporary(

	Graphics.Blit(tex, tmp);
	RenderTexture previous =; = tmp;

	myTexture2D.ReadPixels(new Rect(0, 0, tmp.width, tmp.height), 0, 0);
	//myTexture2D.Apply(); // no need = previous;

	return myTexture2D;

It returns a readable texture from the external texture. It works. But it is quite slow, and creates a lot of garbage with the GetPixels() that will be done after.

Is there a way to get the texture pixel for Editor/Android, we assume that we are using OpenGL. (has someone done it?) Is it possible without creating a native plugin (tried it, crashes everytime ^^')

My final goal is to get the average color of the image (video frame).

Thanks in advance,


Scaling down simply uses bilinear interpolation, so you will get the average of the 4 middle pixels, quite bad.

If you’re dealing with the same video, the highest perf you’ll ever get is to do any slow algorithm, store the result in a color array / texture, and use that as your data.

If inaccuracy is okay, just do a getpixels and sample 500 semi-random pixels on the map, that’s how I did it in the Flash days.

If you want both accuracy and dynamic videos, this guy did something that works: