Hello, I want to "analyse" an image with black points, and retrieve the coordinate of black points in a table, for use later. It's possible ? An image like this : Finally i want to increment an object on all points. Thanks in advance
You can use what LeftyRighty recommended to identify all the spots. Iterate over the whole image, for example using nested for-loops (over width and over height), and create a list of the dots you found. Then it's a matter for translating those pixel coordinates from your bitmap to your specific world-coordinates.
Ok... I'm a noob in scripting ^^ I don't understand how to use all of this... Code (JavaScript): #pragma strict function Start () { var texture = Resources.Load("Materials/pixelsNoirs", Texture2D); var color = texture.GetPixel(3,5); Debug.Log(color); } I juste try to display the color of a pixel, but I have an error :
Try adding Debug.Log(texture) directly after the Load command. I bet it didn't load properly. Is "pixelsNoirs" in your Ressources folder? It's actually easier to define a public variable of type Texture2D and then drag'n'drop the relevant texture into the field via the Inspector.
Color ColorImLookingFor = new Color(0.3f,0.2555f,0.045f,1.0f); for(int i =0; i< myTexture.width; i++) { for(int j =0; j < myTexture.height; j++) { Color thisColor = myTexture.GetPixel(i,j); if(thisColor == Color.black) { //create instance here } //or if(thisColor.r == ColorImLookingFor) { //create instance here } //or if(thisColor.r == 0.0f && thisColor.g == 0.0f && thisColor.b == 0.0f && this.Color.a == 1.0f) { //create instance here } } }