x


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?

more ▼

asked Dec 12 '11 at 08:55 PM

Somian gravatar image

Somian
206 35 46 52

(comments are locked)
10|3000 characters needed characters left

1 answer: sort oldest

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.

more ▼

answered Dec 12 '11 at 09:25 PM

DaveA gravatar image

DaveA
26.5k 151 171 256

almost perfect. however, i have to run the game at least once in order to place all orbs on top of the plane. this isn't too bad but i'd like to see them in their final position immediately without starting the game

Dec 13 '11 at 12:06 AM Somian
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1673
x36

asked: Dec 12 '11 at 08:55 PM

Seen: 979 times

Last Updated: Dec 13 '11 at 12:06 AM