- Home /
Editor Handles Vertex Snap not working on script's object.
Ok, so I am making an object that needs relative points. Since there are going to be a lot of these objects I didn't want to use an empty game object for each one of these relative points. After writing an editor script I can move the points in the scene view by using handles. Thankfully vertex snap works with this and I can snap the points to vertices on my object.
Only that was when the script that has the editor was on an empty child (this was because I was making this from a prototype that needed game objects and colliders and I needed it to be organized, hence starting off with a child object). Now that the script is on the root object the handles won't vertex snap to it.
Now I get why this is happening. Unity doesn't want to detect it's own object because it would be in the way, but that is not what I want and would like to override it. Is there a way around this? My first attempt was to deselect the object but that meant that the editor was disabled too (duh). I guess I could make it work by using an editor window that loads the points and then saves them back to the object I want ... but that seems like a lot of extra work on top of what I have done and another thing to keep updated. I would almost want to just use an empty child object.
Because the project had to move along I did move everything to an editor window and it works fine but it is still a shame that I can't keep the editor on the actual object. I like to keep windows as abstracts or solely tools. So still looking out for a solution to the problem!
You can keep an editor open by adding an additional inspector window in Unity, select the object with the custom inspector and press the lock icon on one of the inspector windows. Now when you deselect the object or when you selecting another object the locked inspector will still show the first selected object.
You can open as many Inspector windows you like (or you have space for :))
This worked. Since I only need one inspector I just deselect the object and move the handles after locking the inspector. I should have thought of that! But it is still a step that might be forgotten and then you need to unlock the inspector afterwards ... maybe i can lock and unlock the inspector using reflection http://answers.unity3d.com/questions/36131/editor-multiple-inspectors.html ... and then it might just break if source code changes.
I now this comment comes VERY late, but thanks a lot for that! I really didn't think about the lock feature despite I use that a lot for other stuff. This just saved me a ton of time. :D