public void Update(BehaviorWindow window, Event currentEvent) { window.wantsMouseMove = true; switch (currentEvent.type) { case EventType.ScrollWheel: this.UpdateZoom(window, currentEvent); break; case EventType.MouseDrag: if (currentEvent.button == 0) { if (this.draggingNode) { this.UpdateDragNode(window, currentEvent); } else if (this.draggingPort) { this.UpdateDragPort(window, currentEvent); } } else if (currentEvent.button == 1 || currentEvent.button == 2) { this.UpdatePan(window, currentEvent); } break; case EventType.MouseDown: this.UpdateMouseDown(window, currentEvent); window.Repaint(); break; case EventType.MouseUp: this.UpdateMouseUp(window, currentEvent); window.Repaint(); break; case EventType.ValidateCommand: case EventType.ExecuteCommand: this.UpdateCommands(window, currentEvent); break; } if (!HOVER_IS_TOOLBAR && !HOVER_IS_BLACKBOARD) { Vector2 position = currentEvent.mousePosition; MOUSE_POSITION = window.WindowToGridPosition(position); } }
private void UpdateDragNode(BehaviorWindow window, Event currentEvent) { Vector2 mousePosition = window.WindowToGridPosition(currentEvent.mousePosition); for (int i = 0; i < Selection.objects.Length; ++i) { if (Selection.objects[i] is Node) { Node node = Selection.objects[i] as Node; int nodeID = node.GetInstanceID(); NodeEditor nodeEditor = window.behaviorGraphEditor.nodeEditors[nodeID]; Vector2 nodePosition = mousePosition + dragOffsets[i]; if (GRID_SNAP) { nodePosition = new Vector2( Mathf.Round(nodePosition.x), Mathf.Round(nodePosition.y) ); } nodeEditor.SetEditorPosition(nodePosition); window.behaviorGraphEditor.RearrangeExecutionIndexes(node.input); } } window.Repaint(); }
// PRIVATE METHODS: ----------------------------------------------------------------------- private void PaintBlackboard(BehaviorWindow window, Event currentEvent) { bool show = GUILayout.Toggle( window.windowBlackboard.GetShow(), GC_BLACKBOARD, EditorStyles.toolbarButton ); window.windowBlackboard.Show(show); window.Repaint(); }
private void PaintZoom(BehaviorWindow window, Event currentEvent) { float zoom = GUILayout.HorizontalSlider( window.windowEvents.zoom, BehaviorWindowEvents.MIN_ZOOM, BehaviorWindowEvents.MAX_ZOOM, GUILayout.Width(ZOOM_WIDTH) ); if (!Mathf.Approximately(zoom, window.windowEvents.zoom)) { window.windowEvents.SetZoom(zoom); window.Repaint(); } }
private void UpdatePan(BehaviorWindow window, Event currentEvent) { if (HOVER_IS_BLACKBOARD || HOVER_IS_TOOLBAR) { return; } Vector2 tmpOffset = this.pan; tmpOffset += currentEvent.delta * zoom; tmpOffset.x = Mathf.Round(tmpOffset.x); tmpOffset.y = Mathf.Round(tmpOffset.y); this.pan = tmpOffset; window.behaviorGraphEditor.UpdateGraph(this.pan, this.zoom); window.Repaint(); }
// UPDATE METHODS: ------------------------------------------------------------------------ private void UpdateZoom(BehaviorWindow window, Event currentEvent) { if (HOVER_IS_BLACKBOARD || HOVER_IS_TOOLBAR) { return; } if (currentEvent.delta.y > 0) { this.SetZoom(zoom + 0.1f * zoom); } else { this.SetZoom(zoom - 0.1f * zoom); } window.behaviorGraphEditor.UpdateGraph(this.pan, this.zoom); window.Repaint(); }
private void UpdateCommands(BehaviorWindow window, Event currentEvent) { bool isDeleteCommand = (currentEvent.commandName == "SoftDelete"); isDeleteCommand |= ( SystemInfo.operatingSystemFamily == OperatingSystemFamily.MacOSX && currentEvent.commandName == "Delete" ); if (isDeleteCommand) { if (currentEvent.type == EventType.ExecuteCommand) { this.RemoveSelectedNodes(window); } currentEvent.Use(); window.Repaint(); } }
private void UpdateDragPort(BehaviorWindow window, Event currentEvent) { window.Repaint(); }