Search Issue Tracker
By Design
Votes
0
Found in
2020.3.37f1
2021.3.8f1
2022.1.12f1
2022.2.0b3
2023.1.0a4
Issue ID
UUM-11372
Regression
No
MouseUp Event is not called when clicking Mouse's left button
Reproduction steps:
# Open the attached project
# Open the Scene View
# Open the Custome Editor Window (Tools > EasyPlace)
# Test all of the mouse buttons in the Scene View
# Observe the outputs in the Console window
Expected result: All of the mouse buttons output mouseUp and mouseDown logs in the Console
Actual result: Mouse left-click doesn’t log the mouseUp message in the Console
Bug is specific to SceneView.duringSceneGui
Reproducible with: 2020.3.37f1, 2021.3.8f1, 2022.1.12f1, 2022.2.0b3, 2023.1.0a4
Reproducible on: Windows 10 (21H2)
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- The Scrollbar becomes unusable when adding Elements to the List
- "One or more data file missing for baking set NewScene Baking Set. Cannot load shared data." error in Player when a specific project is built
- Choosing new HDR Colour using RGB values breaks colour on Intensity Selectors
- Rendering/Decal Layer Mask options are different inside Prefab Mode and outside Prefab Mode when the project is upgraded to Unity 6
- Incorrect Realtime GI Light Probes baking when more than one Light Probe Group is used and "Baked Global Illumination" is enabled
Resolution Note:
The mouse up event is being used by the Scene View to pick objects. To register a user control for mouse button events you need to interface with the hotControl mechanisms.
using UnityEngine;
using UnityEditor;
public class Test : EditorWindow
{
[MenuItem("Tools/EasyPlace &%g")]
public static void Snapper() => GetWindow<Test>("EasyPlace");
void OnEnable() => SceneView.duringSceneGui += DuringSceneGui;
void OnDisable() => SceneView.duringSceneGui -= DuringSceneGui;
static void DuringSceneGui(SceneView sceneView)
{
Event evt = Event.current;
int id = GUIUtility.GetControlID(FocusType.Passive);
// Mouse button 0 is used by the scene view to pick GameObjects. In order to capture mouse events for the left
// button you will need to make the GUI system aware of your intent to use the event.
switch (evt.type)
{
case EventType.Layout:
case EventType.MouseMove:
// AddDefaultControl means that if no other control is selected, this will be chosen as the fallback.
// This allows things like the translate handle and buttons to function.
HandleUtility.AddDefaultControl(id);
break;
case EventType.MouseDown:
if (evt.button == 0 && HandleUtility.nearestControl == id)
{
Debug.Log("mouse button 0 down");
// Setting the hotControl tells the Scene View that this mouse down/up event cannot be considered
// a picking action because the event is in use.
GUIUtility.hotControl = id;
evt.Use();
}
break;
case EventType.MouseUp:
{
if (evt.button == 0 && GUIUtility.hotControl == id)
{
Debug.Log("mouse button 0 up");
GUIUtility.hotControl = 0;
evt.Use();
}
break;
}
}
}
}