pixel = tex.GetPixels**()**;
foreach(Color obj in pixel)
{
print(obj);
pos.x = insx ;
pos.y = insy ;
pos.z = Position.z ;
GameObject S = Instantiate(Slave,pos,Quaternion.identity) as GameObject ;
S.transform.parent = this.transform ;
insx -= 0.55f ;
}
Hi, How can I get the color of a pixel from 2Dtexture and test if it’s white or black ? thanks
var absColor = color.r + color.g + color.b;
if(absColor > 2.9) //white
else if(absColor < 0.1) //black
else //somewhere in-between
Regards,
-Lincoln Green
the texture is black and white but he prints 1.2 ,1.7,2.6 ect… never superior to 2.9 or less than 0.1
.
do you have any idea whats the problem ?
Why bother adding the RGB values?
foreach (Color c in pixels)
{
if (c == Color.black)
{
}
else if (c == Color.white)
{
}
}