Hello, My name is Jade,
I’m trying to get the Color of a pixel from a texture called “scoreMap”.
The code I have is
public int getScoreValue(Vector2 uvCoord)
{
//First, get the pixel color of that uvCoord
int pixelX = (int)(uvCoord.x * scoreMap.width);
int pixelY = (int)(uvCoord.y * scoreMap.height);
Debug.Log("X: " + pixelX + " Y: " + pixelY);
Color pixelColor = scoreMap.GetPixel(pixelX,pixelY);
Debug.Log("Color: " + pixelColor);
...
}
However, I get the log error:
x == 0 && y == 0 && blockWidth == dataWidth && blockHeight == dataHeight UnityEngine.Texture2D:GetPixel(Int32, Int32) ScoreMap:getScoreValue(Vector2) (at Assets/ScoreMap.cs:33)'
Which comes from line 9 : “Color pixelColor = scoreMap.GetPixel(pixelX,pixelY);”
scoreMap is a 512x512 texture, and the pixels I’m feeding the method are valid.
Here’s a picture of the output:
Interestingly enough, it does return the correct color for that pixel on my texture, but it fills my log with error messages and butchers my FPS. Does anyone here know what could be causing this?
Also, my texture settings for scoreMap:
Thanks,