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?