- Home /
 
               Question by 
               MattSawrey · May 01, 2017 at 08:01 PM · 
                eventonsceneguimousedrag  
              
 
              Can't get mouseDrag event in Custom OnSceneGUI
I'm writing a custom editor and in my OnSceneGUI I want to use a mouseDrag event, but I'm not getting one from the left mouse button. Instead I'm getting a "used" event.
I do get mouseDrag events from the middle mouse button and the right mouse button, but not from the left mouse button.
I think it could have something to do with the mouseDrag already being processed for the normal selection box that gets drawn in the scene view when you click and drag the left mouse button.
If anyone knows why I might not be getting a mouseDrag event, that would be much appreciated.
Here's the relevant code:
     protected void ProcessEvents()
     {
         currentEvent = Event.current;
 
         Debug.Log(currentEvent.type);
 
         //Stop clicks on the menu from registering
         if (currentEvent.type == EventType.mouseDown && currentEvent.button == 0 &&
             menuRect.Contains(mousePositionReal))
         {
             currentEvent.Use();
             return;
         }
         
         switch (seletedTool)
         {
             case CharacterPathTools.AddPosition:
                 if (currentEvent.type == EventType.mouseDown && Event.current.button == 0)
                 {
                     characterPath.positions.Add(snapPositionsToGrid ? gridSnappedMousePosition : mousePosition);
                     currentEvent.Use();
                 }
                 break;
             case CharacterPathTools.MovePositions:
                 if (currentEvent.type == EventType.mouseDown && currentEvent.button == 0)
                 {
                     mouseDownPosition = mousePositionReal;
                 }
                 if (currentEvent.type == EventType.mouseDrag && currentEvent.button == 0)
                 {
                     mouseDraggedPosition = mousePositionReal;
                     DrawSelectionBox();
                     FindPointsInSelectionRect();
                 }
                 break;
             case CharacterPathTools.DeletePosition:
                 closestPointIndex = characterPath.GetNearestPathPositionIndex(mousePosition);
                 if (currentEvent.type == EventType.mouseDown && Event.current.button == 0)
                 {
                     characterPath.positions.RemoveAt(closestPointIndex);
                     closestPointIndex = characterPath.GetNearestPathPositionIndex(mousePosition);
                     EditorUtility.SetDirty(characterPath);
                     currentEvent.Use();
                 }
                 break;
         }
 
         //make the scene view update constantly when this editor is working
         if (Event.current.type == EventType.MouseMove)
             SceneView.RepaintAll();
 
         //Stop this gameobject from being deselected on scene view clicks
         Selection.activeGameObject = characterPath.transform.gameObject;
     }
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
               
 
			 
                