public override void GUIView(Event e) { base.GUIView(e); EditorZoomArea.Begin(zoomScale, viewRect); { //DrawGrid(20.0f , 0.5f, Color.gray); //DrawGrid(100.0f , 0.2f, Color.black); if (tempConnect != null) { tempConnect.DrawByMouse(zoomCoordsOrigin, AdvancedStateMachineEditorWindow.Instance.selectNode.rect.center, zoomMousePos); GUI.changed = true; } if (!AdvancedStateMachineEditorWindow.Instance.propertiesView.isHightLight) { DrawNormalNode(); } else { DrawHightlightNode(); } } EditorZoomArea.End(); //GUI.Label(new Rect(245, 0, 300, 50), "viewRect" + viewRect.ToString()); //GUI.Label(new Rect(245, 50, 300, 50), "zoom mousePos" + zoomMousePos.ToString()); //GUI.Label(new Rect(245, 100, 300, 50), "origin mousePos" + originMousePos.ToString()); //GUI.Label(new Rect(245, 150, 300, 50), "coord" + zoomCoordsOrigin.ToString()); //GUI.Label(new Rect(245, 200, 300, 50), new Rect(originMousePos.x - viewRect.x - zoomCoordsOrigin.x, originMousePos.y - viewRect.y - zoomCoordsOrigin.y, viewRect.width, viewRect.height).ToString()); //GUI.Label(new Rect(245, 250, 300, 50), "zoomScale" + zoomScale.ToString()); }
public override void ProcessEvents(Event e) { if (e.type == EventType.Layout) { return; } originMousePos = e.mousePosition; if (!viewRect.Contains(e.mousePosition)) { return; } if (ProcessContextMenu(e)) { return; } EditorZoomArea.Begin(zoomScale, viewRect); { zoomMousePos = e.mousePosition; if (e.type == EventType.MouseDown || e.type == EventType.MouseUp || e.type == EventType.MouseDrag) { if (!e.alt && ProcessNodeEvents(e)) { //## 최적화를 위해서 따로 뺴야한디 if (AdvancedStateMachineEditorWindow.Instance.selectNode != null) { if (!AdvancedStateMachineEditorWindow.Instance.selectNode.isSelected) { AdvancedStateMachineEditorWindow.Instance.SelectNode(null); } } return; } } switch (e.type) { case EventType.MouseDown: { if (e.button == 0 && !e.alt) { if (isConnectionStart) { ClearConnectionSelection(); } //## 최적화를 위해서 따로 뺴야한디 if (AdvancedStateMachineEditorWindow.Instance.selectNode != null) { if (!AdvancedStateMachineEditorWindow.Instance.selectNode.isSelected) { AdvancedStateMachineEditorWindow.Instance.SelectNode(null); } } } if (e.button == 0 && e.alt) { isDragStart = true; if (isConnectionStart) { ClearConnectionSelection(); } } else if (e.button == 1 && !e.alt) { if (isConnectionStart) { ClearConnectionSelection(); } } GUI.changed = true; e.Use(); } break; case EventType.MouseUp: { isDragStart = false; drag = Vector2.zero; GUI.changed = true; e.Use(); } break; case EventType.MouseDrag: if ((isDragStart && e.button == 0 && e.alt) || (isDragStart && e.button == 2)) { Vector2 delta = Event.current.delta; delta /= 1.0f; zoomCoordsOrigin -= delta; drag = delta; e.Use(); GUI.changed = true; } break; case EventType.ScrollWheel: { Vector2 screenCoordsMousePos = Event.current.mousePosition; Vector2 delta = Event.current.delta; Vector2 zoomCoordsMousePos = ConvertScreenCoordsToZoomCoords(screenCoordsMousePos); float zoomDelta = -delta.y / 150.0f; float oldZoom = zoomScale; zoomScale += zoomDelta; zoomScale = Mathf.Clamp(zoomScale, minZoomScale, maxZoomScale); zoomCoordsOrigin += (zoomCoordsMousePos - zoomCoordsOrigin) - (oldZoom / zoomScale) * (zoomCoordsMousePos - zoomCoordsOrigin); e.Use(); GUI.changed = true; } break; //====================================================== //## TODO //====================================================== case EventType.KeyDown: { if (e.control && e.keyCode == KeyCode.S) { AdvancedStateMachineEditorWindow.Instance.SaveData(); e.Use(); } else if (e.control && e.keyCode == KeyCode.D) { //Copy AdvancedStateMachineEditorWindow.Instance.CopyNode(); } else if (e.keyCode == KeyCode.Delete) { if (AdvancedStateMachineEditorWindow.Instance.selectNode != null) { AdvancedStateMachineEditorWindow.Instance.DeleteNode(AdvancedStateMachineEditorWindow.Instance.selectNode); e.Use(); } } } break; }//end switch } EditorZoomArea.End(); }