How to get pixel position when clicking an object ?

Hello,

The (0,0) position of an object texture is in the left-bottom of the object, suppose i clicked on the object in that exact position, how can i get these (0,0) ?

i tried to do something like this but it wasn’t precise :

objectPoint = Camera.main.WorldToScreenPoint (transform.position);
				objectSize = new Vector3 (targetTexture.width, targetTexture.height, 0);
				mousePoint = Input.mousePosition;
				PixelPoint.x = mousePoint.x - (objectPoint.x - (objectSize.x / 2));	
				PixelPoint.y = mousePoint.y - (objectPoint.y - (objectSize.y / 2));	

thank you

Generally this is done using Raycasting. You Raycast against the texture using one of the versions of Raycast that take a RaycastHit structure as a parameter. One of the things RaycastHit returns is the RaycastHit.textureCoord. This is the UV coordinate of the hit on the texture. UV coordinates go from 0 to 1, so you have to multiple the width and height by textureCoord.x aand textureCoord.y respectively to get the pixel position.