public static void HandleKeyAndMouseMove(int id) { Event current = Event.current; switch (current.GetTypeForControl(id)) { case EventType.MouseMove: if (!Tools.vertexDragging) { break; } VertexSnapping.EnableVertexSnapping(id); current.Use(); break; case EventType.KeyDown: if (current.keyCode != KeyCode.V) { break; } if (!Tools.vertexDragging && !current.shift) { VertexSnapping.EnableVertexSnapping(id); } current.Use(); break; case EventType.KeyUp: if (current.keyCode != KeyCode.V) { break; } if (current.shift) { Tools.vertexDragging = !Tools.vertexDragging; } else if (Tools.vertexDragging) { Tools.vertexDragging = false; } if (Tools.vertexDragging) { VertexSnapping.EnableVertexSnapping(id); } else { VertexSnapping.DisableVertexSnapping(id); } current.Use(); break; } }
public static void HandleKeyAndMouseMove(int id) { Event current = Event.current; EventType typeForControl = current.GetTypeForControl(id); if (typeForControl != EventType.MouseMove) { if (typeForControl != EventType.KeyDown) { if (typeForControl == EventType.KeyUp) { if (current.keyCode == KeyCode.V) { if (current.shift) { Tools.vertexDragging = !Tools.vertexDragging; } else if (Tools.vertexDragging) { Tools.vertexDragging = false; } if (Tools.vertexDragging) { VertexSnapping.EnableVertexSnapping(id); } else { VertexSnapping.DisableVertexSnapping(id); } current.Use(); } } } else if (current.keyCode == KeyCode.V) { if (!Tools.vertexDragging && !current.shift) { VertexSnapping.EnableVertexSnapping(id); } current.Use(); } } else if (Tools.vertexDragging) { VertexSnapping.EnableVertexSnapping(id); current.Use(); } }