Search Unity

2020.2 broke Handles.Button registering click in sceneview while alt is being held.

Discussion in 'Editor & General Support' started by pastaluego, Dec 26, 2020.

  1. pastaluego

    pastaluego

    Joined:
    Mar 30, 2017
    Posts:
    196
    Code (CSharp):
    1.  
    2. private void OnSceneGUI()
    3.     {
    4.         if(Event.current.alt)
    5.         {
    6.             if(Handles.Button(HandlePosition, Quaternion.identity, 2, 2, Handles.ConeHandleCap))
    7.             {
    8.                 Debug.Log("This Debug.Log will never occur");
    9.             }
    10.         }
    11.     }
    12.  
    In 2020.2+, that code is failing to register the button click when alt is being held for the button to appear.

    I believe it's because of a recent change Unity made to fix this bug:
    https://issuetracker.unity3d.com/is...-rotation-when-mouse-hovering-over-the-button

    I believe that whatever they did to fix that bug caused this unintended side effect. I could be wrong on that but the time lines up with when this started occurring. And the 2020.2 Patch notes state
    • Editor: Fixed an issue where Handles.Button prevented Scene View navigation. (1250996)
    And sceneview navigation is done via alt+clickdrag. So my assumption is that that change is what affected it.

    From I believe 5.4 to 2020.1 this script has worked as expected, with it now not working in 2020.2+ It might be that you now need to assign a custom control ID to the GUIUtility.hotcontrol to override the sceneview navigation that now overrides the lack of a custom control ID for Handles.Button, but I don't know enough to comment on that.

    Made bug report: Case ID: 1301950
     
    Last edited: Dec 27, 2020
  2. pastaluego

    pastaluego

    Joined:
    Mar 30, 2017
    Posts:
    196
    I tried messing around with setting GUIUtility.hotControl and Event.current.Use() on certain events with some success, but not complete success. By setting the hotcontrol I could get the editor script to completely ignore the SceneView navigation Event which would let the Handles.Button trigger, but it was not reliable and I could not manage to return hotControl to SceneView Navigation after keyup because I am not sure how to get its controlID.
     
  3. samanabo

    samanabo

    Joined:
    Mar 10, 2015
    Posts:
    51
    I am also running into this issue, a few plugins appear to have broken because of this change. I would be very interested in any solutions people have found.
     
  4. pastaluego

    pastaluego

    Joined:
    Mar 30, 2017
    Posts:
    196
    Sadly my bug report was responded to that said the dev who made the fix says it is intentional and that sceneview navigation should override all editor scripts when pressing alt.

    Which to me doesn't seem right given how many other built-in editor functions can get overridden via editor script, but I didn't argue. Especially since the button click still goes through visually when you press a Handles.Button holding alt, but the onclick just doesn't activate.

    I'm convinced the dev is wrong but again it's easier for me to just change it from alt than to argue and wait for a fix.
     
  5. Creta_Park

    Creta_Park

    Joined:
    Mar 11, 2016
    Posts:
    76
    Same here, I was using Ferr2D, holding alt with click function was delete point on terrain, it's not work after update.