How can I change all of a textures pixels to one color?

I have a painting app in which colors are painted over the top of a completely transparent, blank texture. I need to create a “clear” functionality where all the pixels in the texture are reset to a specific color (1, 1, 1, 0); which is a completely transparent white. Rather than changing out the texture each time, I would rather simply wipe all the pixels on the one texture. Here is what I’ve got so far but it’s not working:

#pragma strict

var resetColor : Color = Color(1, 1, 1, 0);
var tex : Texture2D;
var resetColorArray = new Array ();

function Start () {

	tex = renderer.material.GetTexture ("_MainTex");
	resetColorArray =  tex.GetPixels();


function Update () {
	if (Input.GetKeyDown(KeyCode.Return)) {
		for(var i = 0; i < resetColorArray.length; ++i)
		    resetColorArray *= resetColor;*
  •  }*
  •  tex.SetPixels( resetColorArray );*
  •  tex.Apply();*
  • } *
    How can I do this?

The resetTextureArray needs to be either a Color array, or preferably a Color32 array, which you can use with SetPixels32. Never use the Array class (for this or anything else; it’s useless). Also resetTextureArray should ideally be filled once in Start, rather than every time you hit return.