Game Dev - Snap to Grid

I got a seat on the train today and started messing around with generating a grid and a grid object that you can place on top of the grid. I wanted it to do "snap to grid" as well, so wherever you let go (on top of the grid), it will snap into place.

The code looks a little hacky and requires some mouseEnable = false/true shenanigans, but I'm thinking this will serve my purposes.

This is actually for a card game I worked on the other week and decided to do a coded version for testing.