Hi!
How would i do if i want if-statements to start working after eachother? I am making a script that filters out greyish pixels and replaces them with either black or white pixels, after this procedure i want to color the outline of the black pixels red.
This is a fraction of my code with the if statements:
for (int x = 0; x < image.width; x++){
for (int y = 0; y < image.height; y++){
color = pixels[(y * image.height)+x];
obj = GameObject.CreatePrimitive(PrimitiveType.Cube);
obj.transform.position = new Vector3 (x, y, 0);
obj.renderer.material.color = color;
if (0 < color.b && color.b < Color.gray.b && filter == true)
{
s = s + 1;
obj.renderer.material.color = Color.black;
}
if (Color.gray.b < color.b && color.b < 1 && filter == true)
{
s = s + 1;
obj.renderer.material.color = Color.white;
}
if (color == Color.black && pixels[(y * image.height)+x-1] == Color.white)
{
obj.renderer.material.color = Color.red;
p = p + 1;
}
}
}
The problem is that the scripts first colors the pixels red, and then filters out the grey pixels. Since the grey pixels arent white or black yet i get some pixels that should be red but arent (the ones that originaly was grey).
Can someone give me some tips on how to run the third if-statement after the two previous ones?
Thank you!
//Taegos
Can you make an example please?
– Tageos