12

I would like to make all the handles in my editor to show even when a given game object is not selected, in such a way that when the mouse point hovers over a given handle it becomes selectable. How can I do this?

Bane
  • 341
  • 1
  • 17
  • `GameObject SelectedObject = Selection.activeTransform.gameObject;` You can use this to get the current gameObject. After this, you can instantiate a cube (or anything) in it's position. This will let you see the position of the gameobject at all times. Furthermore, you can also check to see if the mouse is over the instantiated object or not and make it selectable. – Rishi Jan 17 '18 at 13:44

1 Answers1

1

See here, how to make custom handles?

There is recommended JetBrains DotPeek.

The most important things to understand are (A) the use of HandleUtility.nearestControl and HandleUtility.hotControl to manage input focus, with IDs generated by GUIUtility.GetControlID() and (B) the way OnSceneGUI is called multiple times for different events requiring very different handling.

Use it like:

void OnSceneGui()
{
   MyHandles.DragHandleResult dhResult;
   Vector3 newPosition = MyHandles.DragHandle(position, size, Handles.SphereCap, Color.red, out dhResult);

   switch (dhResult)
   {
   case MyHandles.DragHandleResult.LMBDoubleClick:
       // do something
       break;
   }
}