GUI.GetNameOfFocusedControl & GUI.SetNextControlName issues Unity 2017.2

Hi All
Is anyone else having problems with GUI.GetNameOfFocusedControl & GUI.SetNextControlName in Unity 2017.2? Editor scripts that have worked in all versions of Unity up to 2017.2 and also work in 2017.3 don’t work in 2017.2 because GetNameOfFocusedControl is always returning an empty string. Is there a know issue or any workaround, the fact the scripts work in 2017.1 and 2017.3 but not 2017.2 makes me think there is something going on in Unity.
Chris

I’ve also encountered this. A Unity extension I develop is now broken because of this. Trying to figure out how to fix this.

Downloaded newly released 2017.3 and it still doesn’t work. I wonder if there’s a workaround for this.

Same problem here in latest version: 2017.3.0f3.
Haven’t found any workarounds yet…

I’ve found a workaround some time ago. It’s a different approach but it works for me. Here’s how I do it. When creating a control, you can pass the custom cap function instead of the default one:

Vector3 point=Handles.FreeMoveHandle(
            script.transform.TransformPoint(script.points[i].position),
            script.transform.rotation,
            size,
            Vector3.zero,
            CircleHandleCapSaveID //A name of a custom cap function
        );

Custom cap function looks like this. It just wraps around default cap function but since it receives controlID, it can pass it to current object. So after creating a control you can add its ID to some array/list to remember which control has which ID.

    public void CircleHandleCapSaveID(int controlID,Vector3 position,Quaternion rotation,float size,EventType et){
        lastControlID=controlID; //
        Handles.CircleHandleCap(controlID,position,rotation,size,et);
    }

And when I have this array of IDs I can compare them to GUIUtility.hotControl to get which one is currently focused. This is how I do after control names stopped working.

1 Like