public void DrawNodeEditor(Rect LayoutPosition) { if (isSetupRequested) { Setup(); } panelSize = new Vector2(LayoutPosition.width, LayoutPosition.height); editorScrollPos = EditorGUILayout.BeginScrollView(editorScrollPos, false, false, GUILayout.Width(LayoutPosition.width), GUILayout.Height(LayoutPosition.height)); GUILayoutOption[] options = { GUILayout.Width(editorScrollSize.x), GUILayout.Height(editorScrollSize.y) }; EditorGUILayout.LabelField("", options); var backgroundTint = Color.white; if (isInstance && constellationScript.IsDifferentThanSource) { backgroundTint = Color.yellow; } Background.DrawBackgroundGrid(LayoutPosition.width, LayoutPosition.height, GetCurrentScrollPosX(), GetCurrentScrollPosY(), backgroundTint); NodeEditorNodes.DrawEditorNodes(editorScrollPos); NodeEditorLinks.DrawLinks(); EditorGUILayout.EndScrollView(); if (isInstance) { DrawInstancePannel(); } editorScrollSize = new Vector2(NodeEditorNodes.GetFarNodeX() + 400, NodeEditorNodes.GetFarNodeY() + 400); nodeEditorSelection.Draw(NodeEditorNodes.GetNodes().ToArray(), GetLinks(), editorScrollPos, LayoutPosition); if (Event.current.button == 2) { editorScrollPos -= Event.current.delta * 0.5f; RequestRepaint(); } }
public void Draw(ConstellationEditorEvents.RequestRepaint requestRepaint, ConstellationEditorEvents.EditorEvents callback, ConstellationEditorStyles constellationEditorStyles, out Vector2 windowSize, out Vector2 scrollPosition) { mouseButtonDown = false; //scroll bar ScrollPosition = EditorGUILayout.BeginScrollView(ScrollPosition, GUILayout.Width(windowSizeX), GUILayout.Height(windowSizeY)); GUILayoutOption[] options = { GUILayout.Width(editorScrollSize.x), GUILayout.Height(editorScrollSize.y) }; editorScrollSize = new Vector2(farNodeX + 400, farNodeY + 400); windowSize = editorScrollSize; scrollPosition = ScrollPosition; EditorGUILayout.LabelField("", options); var backgroundTint = Color.white; if (ConstellationScript.IsInstance && ConstellationScript.IsDifferentThanSource) { backgroundTint = Color.yellow; } background.DrawBackgroundGrid(windowSizeX, windowSizeY, ScrollPosition.x, ScrollPosition.y, backgroundTint); Event e = Event.current; var mouseJustRelease = false; if (e.type == EventType.MouseUp && Event.current.button == 0 && mousePressed == true) { mouseJustRelease = true; mousePressed = false; } else if (e.type == EventType.MouseDown && Event.current.button == 0) { mouseClickStartPosition = e.mousePosition; mousePressed = true; mouseButtonDown = true; } switch (currentEventScope) { case EventsScope.Generic: UpdateGenericEvents(requestRepaint, callback, e); break; case EventsScope.Resizing: UpdateResizeEvents(requestRepaint, callback, e); break; case EventsScope.Dragging: UpdateDragEvents(requestRepaint, callback, e); break; case EventsScope.EditingAttributes: break; case EventsScope.Selecting: UpdateSelectEvent(requestRepaint, constellationEditorStyles); break; } //Needs to be called after the event scope otherwise quit button event is overriden by the node drag event if (mouseJustRelease) { currentEventScope = EventsScope.Generic; for (var i = 0; i < Nodes.Count; i++) { Nodes[i].LockNodeSize(); Nodes[i].LockNodePosition(); } } DrawNodes(e); Links.DrawLinks(requestRepaint, callback, constellationEditorStyles); DrawDescriptions(e); EditorGUILayout.EndScrollView(); if (Event.current.button == 2) { ScrollPosition -= Event.current.delta * 0.5f; requestRepaint(); } var script = ConstellationScript.script; if (script.Nodes != null) { script.Nodes = script.Nodes.OrderBy(x => x.YPosition).ToList(); } if (script.Links != null) { script.Links = script.Links.OrderBy(x => x.outputPositionY).ToList(); } }
public void DrawBackground(Color backgroundTint, float width, float height) { Background.DrawBackgroundGrid(width, height, GetCurrentScrollPosX(), GetCurrentScrollPosY(), backgroundTint); }