I’m trying to hide the Handles on a GameObject, so nobody can move, scale or rotate it. Is there any way to do this, whether in an Editor script or some other way?
Solved my own issue! This seems to work when placed in an Editor script:
The non-hacky and “correct” way of doing this is:
Tool LastTool = Tool.None;
void OnEnable()
{
LastTool = Tools.current;
Tools.current = Tool.None;
}
void OnDisable()
{
Tools.current = LastTool;
}
Do this in your editor class. This will remember the tool that was on, then set it to be no tool (thus no handles), and will restore it once they deselect the object.
Of course while they have it selected they could always select a tool again and then the handles you don’t want will reappear. But this is easy to prevent by just adding:
Tools.current = Tool.None;
somewhere in your OnSceneGUI() method. This forces it off constantly.
Hiding it with the hack works… but is not the documented way to do it and requires reflection to sneak into private fields of the Tools class. Doing that could break in the future since that’s private functionality.
David