Question by
thishereguy · Jun 29, 2016 at 05:52 AM ·
texture2dresources.loadgetpixel
Use getPixel on a resource.
So i am trying to get the color of a pixel at a coordinate on a image in my resource folder. I get the coordinate by clicking on a similar image in-game. But i get a error message when i try to get the pixel color from the image from my resource folder.
underneath = (Texture2D)Resources.Load("underlay.png");
var pixelColor = underneath.GetPixel(Mathf.RoundToInt(x), Mathf.RoundToInt(y));
Debug.Log(pixelColor);
Yeah and i get the error: NullReferenceException: Object reference not set to an instance of an object
Does that mean i have to use the image in game to get the color from it? How can i bypass that?
Comment
Your answer
Follow this Question
Related Questions
Texture manipulation 0 Answers
Get Colors from RenderTexture faster! 1 Answer
Turning every color in an image to many GameObjects ? 0 Answers
Drawing performance issues. Color32.op_lmplicit() very slow 0 Answers
Resources.Load doesn't work 1 Answer