- Home /
Check if mouse is down while in Edit Mode
How can I simply check if the mouse if held while in edit mode? The edit mode equivalent of Input.GetMouseButton(0)
To be clear: I do NOT mean tracking mouse events. I also don't mean for a specific window - I mean at all. There are already tons of answers for specific events and individual windows.
I'm just looking for a straight-up solution for "is the left mouse button currently held". Thank you!
Answer by Captain_Pineapple · Dec 13, 2021 at 12:06 PM
from the category "bodged but works somewhat" i present thee this code:
[ExecuteAlways]
public class testscript :MonoBehaviour
{
public void Update()
{
Debug.Log("Update");
if (Input.GetMouseButton(0))
Debug.Log("testtest");
}
void OnDrawGizmos()
{
// Your gizmo drawing thing goes here if required...
#if UNITY_EDITOR
// Ensure continuous Update calls.
if (!Application.isPlaying)
{
UnityEditor.EditorApplication.QueuePlayerLoopUpdate();
UnityEditor.SceneView.RepaintAll();
}
#endif
}
}
i want to stress the somewhat specifically as this for example can miss clicks if you only check for MouseButtonDown instead of MouseButton.
But perhaps this is something that helps you find a better solution or someone else has something better at hand. Would be curious to see if there is a good solution to this.
Let me know what you think