Detect Editor Manipulation Mode

How would I go about determining what manipulation mode (hand, position, rotation, scale) the editor is in from within an editor script?

the idea is to manipulate handles to respect what mode is currently selected

2 Answers

2

The current tool is stored in Tools.current. You can change this value select another tool or unselect them all by setting it to -1. But it’s undocumented, so things might go wrong. I had some troubles with it until I disable default input handling in the Scene view by calling

HandleUtility.AddDefaultControl(GUIUtility.GetControlID(FocusType.Passive));

in OnSceneGUI()

Update from 2015 as this is high on Google results: The tools class now have the Tool enum, which contains the constants None, View, Move, Rotate, Scale and Rect. So you can check if the move tool is selected by: if (Tools.current == Tool.Move)

@hardwire OMG, it is exactly what I need to detect the default current tool in CustomEditor, following is a quick test:

 public void OnSceneGUI () 
{
        if (GUI.changed)		
         EditorUtility.SetDirty (target);

Debug.Log(" Current Tool: " + Tools.current.ToString()); // results:View,Move,Rotate,Scale
}

Thanks