Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I keep handles always visible in scene while highlighting when selected?

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?

like image 880
Bane Avatar asked Jan 12 '18 09:01

Bane


1 Answers

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;
   }
}
like image 74
stefan Avatar answered Oct 11 '22 17:10

stefan