How the position in a grid 3D when mouse clicked

I everyone,

I’ve a problem and searched in Unity answers and Google answers, but unsuccessfully. I need get (through mouse click) the position (coordinates x, y and z) of point in a simple 3D grid, the coordinates will be use for mark the point like a obstacle (sorry by bad english).

Thanks.

Input.mousePosition gives you the pointer coordinates. and you can use your camera
Camera.main.ScreenToWorldPoint to get a 3D coordinate.
Then once you got that, find the closest point on your grid.