//TODO: this will lock up the Editor while 'moving the mouse'. //We need to decide if this is okay, or not. //This is responsible for showing the mouse moving between mouse events. private void HandleMouseAutomationVisibility(Vector2 desiredMousePosition, bool sendMouseDrag = false) { if (!isAutomationVisible) { return; } if (m_LastMousePosition != desiredMousePosition) { float startTime = (float)EditorApplication.timeSinceStartup; float endTime = startTime + ((m_LastMousePosition - desiredMousePosition).magnitude / m_MouseMoveSpeed); var mouseStart = m_LastMousePosition; while (m_LastMousePosition != desiredMousePosition) { float curtime = (float)EditorApplication.timeSinceStartup; float frac = Mathf.Clamp01((curtime - startTime) / (endTime - startTime)); frac = Easing.Quadratic.InOut(frac); var mousePosition = Vector2.Lerp(mouseStart, desiredMousePosition, frac); //We currently send mouse moves to the window when visualizing the interactions, //But this might create different behaviour when visualizing or not. //This is also true for the Repaint event from RepaintImmediately. //TODO: Decide what to do about it. EventUtility.UpdateMouseMove(window, mousePosition); if (sendMouseDrag) { EventUtility.UpdateDragAndDrop(window, mousePosition); } m_LastMousePosition = mousePosition; window.RepaintImmediately(); System.Threading.Thread.Sleep(16); } } HandleLastEventPauseVisibility(); }