private void ManageClicking() { int controlID = GUIUtility.GetControlID(hash, FocusType.Passive); Event currentEvent = curEvent; bool mouseDown = currentEvent.GetTypeForControl(controlID) == EventType.MouseDown; bool mouseUp = currentEvent.GetTypeForControl(controlID) == EventType.MouseUp; bool mouseDrag = currentEvent.GetTypeForControl(controlID) == EventType.MouseDrag; bool mouseEvent = (mouseDown || mouseUp || mouseDrag); //Type event bool control = currentEvent.control; bool clickL = currentEvent.button == 0; bool clickR = currentEvent.button == 1; bool controlLClick = control && clickL; bool controlRClick = control && clickR; if (mouseDown && (inRangeOfSpline || inRangeOfControlPoint)) { if (controlLClick) // Add Point { Undo.RecordObject(mySpline, "Added Control Point"); mySpline.AddCurveAtPosition(mouseSplinePercentage); //Stupid GUI stuff GUIUtility.hotControl = controlID; currentEvent.Use(); } else if (controlRClick && inRangeOfControlPoint) // Remove Point { // select nearest point selectedIndex = nearestIndex; //Editor.Repaint(); // delete point Undo.RecordObject(mySpline, "Removed Control Point"); mySpline.RemovePoint(selectedIndex); GUIUtility.hotControl = controlID; currentEvent.Use(); } else if (clickL || clickR) //Allow click on spline or points { //Stupid GUI stuff GUIUtility.hotControl = controlID; currentEvent.Use(); if (inRangeOfControlPoint) { selectedIndex = nearestIndex; waitingForDrag = true; //Refresh inspector //Repaint(); } } } else if (!dragging && mouseDrag && waitingForDrag && inRangeOfControlPoint && (clickL || clickR)) { //Which type of drag? if (clickL && !clickR) { BeginDrag(DragType.LeftMouse); } else if (clickR && !clickL) { BeginDrag(DragType.RightMouse); } } else if (mouseUp) { bool timeToEndDrag = false; waitingForDrag = false; //check if correct button was raised if (dragging) { switch (m_dragType) { case DragType.LeftMouse: if (clickL) { timeToEndDrag = true; } break; case DragType.RightMouse: if (clickR) { timeToEndDrag = true; } break; } currentEvent.Use(); } if (timeToEndDrag) { FinishDrag(); } //Stupid GUI stuff if (GUIUtility.hotControl == controlID) { GUIUtility.hotControl = 0; Debug.Log("Releasing spline editor mouse control"); currentEvent.Use(); } } else if (dragging && mouseDrag) { //Continue Drag ManageDrag(selectedIndex); Undo.RecordObject(mySpline, "Move Point"); currentEvent.Use(); } }