3D Translation and Rotation widgets in-game

I looked through the wiki and couldn’t find an example of this, so I thought I’d check here to see if anybody has tried to do this.

What I’m looking to do is provide an in-game tranform widget that allows the user to select an object and either translate or rotate it. I was thinking of just creating 3D objects for the transform and rotation axes and then doing some kind of MouseOver/MouseDown checks to check if the user is dragging the mouse after selecting one of the axes (not sure how difficult this will be). The widgets themselves shouldn’t be affected by zooming though…just like in the Unity editing environment itself. Maybe there will be a 1-to-1 relationship between the viewport zoom and the scale of the widgets?

Has anybody tried to do something like this? I’m creating an app to import a user-specified model and do some collision detection with the pre-built environment mesh…just trying to figure out some of the sticky points.

Thanks in advance for any help!

Cheers,
Josiah

I’m working on something like that. I need and in-game editor to be able to dynamically move, rotate, and scale objects in a scene.

It still needs some work, but I have the 3d transform handles working and they scale with the zoom of the camera. I’m also drawing the wireframe of the mesh (light blue), as well as the colliders (light green).

Here’s some screens from what I have so far.



Where is the example?

Hey Shaneo, that looks awesome!

Do you support keyboard shortcuts too? I know a lot of people, especially working with multiplayer type projects, are looking for the same solution.

It’d be brilliant if you considered putting it out there in the community wiki or somehow made it available.

:slight_smile:

What kind of keyboard shortcuts are you looking for? I’m sure those can be done.
As far as releasing it to the community, if there’s a demand for it then I’m not against putting it out there, although I think I should maybe clean up the code a little before hand :slight_smile:

I’ll try to work on putting together something that you can test out.

What kind of keyboard shortcuts are you looking for?

How about those shortcuts we all know and love? W for move, E for rotation, and R for scale??

demand for it then I’m not against putting it out there
I’m certain it would be a huge hit – there are a lot of people who want to try in-game object placement :smile:

Here’s an example that people can test out. Keep in mind this is only a first pass and there are still some issues to be worked out.

http://shaneo.blogsite.org/Unity/Editor.html

I do now :wink:

Forgot to mention the controls :stuck_out_tongue:

Shift + left click: move camera.
Alt + left click: rotate camera.
mouse wheel: zoom (must have an object selected)
F: focus on selected object
W: move
E: rotate
R: scale

Any object?

Yes, it works for any object.

:slight_smile: :slight_smile: :slight_smile: Thank you,I was entangled to transform GameObject by Gizmos in game(especially for Gizmos display)

This is great Shaneo! I hadn’t looked at this post for ages, so it was nice to come back to your example. :smile: I have a quick question about your script though…is the one on your blog download the latest version? Just creating a new scene and placing a couple objects there, I don’t see any way to switch between translation, rotation, and scaling of the objects. I seem to get a “Matrix stack overflow” when I demo the scene as well, though it seems to have something to do with the Unity trying to draw its built-in GUI handles (this is all will a simple scene started from scratch, with a cube and sphere added and your script attached to the main camera).

I ended up implementing a much less elegant solution, creating actual 3D widget objects. I’m moving the main object around as a kinematic rigidbody and implementing collision detection to keep objects from moving through each other.

Let me know if you have a script update, or if I’m missing something. Thanks for the great example! Let me know if you’d like to see an implementation of collision detection with this.

Cheers,
Josiah

Updated the script to have the rotation and scaling. Not sure why it wasn’t there :sweat_smile:
I’ve attached a sample projects that uses the script. I didn’t get any error when running it.

Of course I do :smile:

154088–5594–$objecteditor_754.zip (1.09 MB)

1 Like

This is a great script. Thank you for sharing.

Sorry to resurrect the dead here but would anyone happen to have an updated version of this script? Just what I was looking for!