place object on a surface in editor

Hi there,
I have a lot of levels to build by dragging & dropping prefabs from the project pane to the editor. These assets are balls that have their pivots at the center. However, i’d like to place them on top of a surface and they’re always half stuck in the ground when I move them on the surface so I always have to incase the Y position for each object i drag in.

Is there a way to place the objects on the surface without being stuck?

While this doesn’t help with the object being placed in the center, the editor supports surface snapping. I’m repeating it here because it’s a bit hard to find and remember.

Surface Snapping

While dragging in the center using the
Translate Tool, you can hold Shift and
Control (Command on Mac) to snap the
object to the intersection of any
Collider. This makes precise
positioning of objects incredibly
fast.

Make a script, and set it to run in Edit mode: http://unity3d.com/support/documentation/ScriptReference/ExecuteInEditMode.html

In the Start function, set the Y position. If you just have a flat plane, it would be a constant, but if it’s a variable surface, you can cast a ray down to find the floor.

Attach it to your prefab.

Have this just run in the editor. You can comment it out or remove it for run-time. But it should help you with initial placement.

Most helpfull thing for that is the Vertex Snap:

Hold V will change the transform point to the nearest Vertex to the mouse cursor - and then snap all movements to vertices on other objects

Source: Unity - Manual: Unity shortcuts