Level Color Map

I’m trying to create a basic level from a image I created in paint.
The script is trying to get each pixel and check its color and compare it to the color I have specified, but it doesn’t seem to ever pass through the if statement.
`
var img : Texture2D;
var grass : GameObject;

function Start () {
	for(var x : int = 0; x < img.width; x++) {
		for(var y : int = 0; y < img.height; y++) {
			Debug.Log(img.GetPixel(x,y));
			if(img.GetPixel(x,y) == Color(0.290, 1.000, 0.000, 1.000)) {
				Debug.Log("working");
				Instantiate(grass, Vector3(x, 0, y), Quaternion.identity);
			}
		}
	}
}

`

The only thing I get in the Console is:(Well acctually 256 times since it’s a 16x16 img) <\br><\br>
RGBA(0.290, 1.000, 0.000, 1.000)<\br>
UnityEngine.Debug:Log(Object)<\br>
Level:Start() (at Assets/Scripts/Level.js:10)<\br>

which I got from the <\br>
Debug.Log(img.GetPixel(x,y));

I don’t see anything wrong with your code as such - I suspect that the problem comes from rounding errors in the color component values (i.e. the Red component of your pixels is not exactly equal to 0.290 - that’s just the truncated value displayed by Debug.Log). As a result, your if condition is never evaluating to true.

Try it with a different image that only has white and black pixels and test for Color(0,0,0,1) and Color(1,1,1,1) - that should work.