So I recently discovered the magic of Vertex Snapping with the move tool, and while it helps a lot with assembling grid-based parts, it can be kind of messy: https://i.imgur.com/Z0vU3fw.png
I’m left with these very tiny errors, and while they probably won’t change anything (besides slightly irritating me every time I open the object) I just wanted to know if there’s any way to round all coordinates with decimals that low in a scene, even if it means I have to make an editor extension.
Well, you could, but unless you’re only dealing with integer values I wouldn’t recommend being bothered by it that much as float values aren’t infinitely precise.
If you are dealing with integer values, then you would have to find a way to bypass Unity’s rounding in lower than and higher than operations for float, OR you would have to write an algorithm that rounds floats to integers, which would basically be something like truncating numbers similar to whole number division. Whatever you do, that algorithm will have to manually overwrite the value Unity keeps.
Overall, I don’t think it’s worth it. Unless your objects are insanely small, the rounding error won’t be significant.
If you want to align things in a grid, you may just adjust the snap setting (Edit → Snap Settings) and hold CTRL while dragging. Note that the grid is always relative to 0,0,0, but you can set any grid spacing you like.
Of course it’s possible to create an editor script that rounds all position values, however it could fail in some edge cases. Especially if two objects are exactly between two snap values. For example if you snap to 0.01. If obj1 has a position of 0.0149999 and obj2 0.01500001, the first one would end up at 0.01 and the second at 0.02. If the values aren’t 100% equal, rounding the positions could transform a tiny cap into a larger one.