Move object arrows

I’m trying to copy the functionality from Unity editor window. When you select the object a set of arrows turns out and you can drag the object regarding to one of them. I tried to set two layers and two cameras so the arrows are always “on top” and visible, but there is a problem with dragging because raycast can hit other objects before arrows. I know another solution: to place arrows in half way between camera and the object and to move it so it looks like it’s in center of the object. But maybe there is a better solution? Maybe there is even a possibility to get the original arrows from editor?

Try using the layermask parameter in the Raycast functions to ignore all layers but those containing the arrows.

I tried but that collides with select/deselect function. I want to change the selection by clicking on different objects in scene so actually I need all layers to be active all time.

well, you have to decide what you want. Should clicking on the object should select it, or activate the arrows?

What I’d suggest is to do a raycast with the layer mask set to only hit the arrows first, and if that fails, do another one to see if you hit any objects.

What I did was render the arrows in OpenGL (so they are always on top) and manually check if the mouse is over the position of the arrows for the currently selected object. If that fails then I check the mouse position with the bounding box of the other objects so they can be selected.

The problem with Raycasts is that your objects must have colliders (in my case is not always true). By detecting it manually you can select objects without colliders as well.

Here’s a sample

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

But perhaps there’s an easier way :stuck_out_tongue:

This example looks really good. I managed to make it my own way (displaying the arrows in half way) but the only problem is that when I move fast the camera around the selected object the arrows moves with a little lag so for a moment it looks like arrows are chaseing the object. I understand that’s no problem in your solution but I think I won’t be able to mess with Opengl so I need to ask if you could make me a big favor and show me the code? I don’t want to be rude or anything just looking for best solution.

Ya, I had the same problem. Which is why I went with the OpenGL version :slight_smile:

Here’s a script that will draw the 3D arrows, the wireframe, and colliders (except for capsule and convex mesh…still have to implement those). If you want the background grid to display set the camera’s clear flags to “Don’t Clear” (the script will clear it).

I am not an OpenGL or 3D programmer so this script is still a work in progress. It will contain bugs and has not been optimized.

142968–5216–$editorcamera_799.cs (23.2 KB)

Thanks a lot. Great stuff.

Yes, I love it :smile: