This site uses cookies! Learn More

This site uses cookies!

armedunity.com uses cookies to improve user experience.

By continuing to use this site, you agree to allow us to store cookies on your computer.

Sign in to follow this  
Followers 0
OcularCash

Simple Object Placer

5 posts in this topic

So this is a pretty noob script but it's useful. Took me a little bit to get it working because, well, I'm sure you know my take on unity C# (not c# in general, just unity's). But this editor allows you to place objects in the scene, parent them while placing (only if parent in not null) and also allows for grid snapping (because I'm a big fan of symmetry). This spawns on left click and can be dragged around, then is placed on left mouse up. Middle mouse button and right mouse button can still move the camera around. Here it is:

 

Placer.cs (Belongs in editor folder)

Please login or register to see this code.

 

ObjectPlacer.cs (Drag it on some object in the scene)

Please login or register to see this code.

 

3 people like this

Share this post


Link to post
Share on other sites

I feel as if I may want to extend on this for my own purposes, thanks Ocular.

Share this post


Link to post
Share on other sites

Forgot anchor offsetting and collider disabling while dragging. It's added now. I was placing grass before which doesn't have a collider and didn't realize I didn't add it until I got around to the trees.

Share this post


Link to post
Share on other sites

i don't see undo registering here

 

Share this post


Link to post
Share on other sites

Because in my case I don't need it. My maps are already drawn up prior to placing. If you need it, just put Undo.RegisterCreatedObjectUndo(instanced, "Instantiation"); that's literally all it is

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0