// GUI function for the main view void DrawMainViewGUI() { FeedbackQueue.Reset(); _scrollMain = EditorGUILayout.BeginScrollView( _scrollMain, false, false, GUIStyles.horizontalScrollbar, GUIStyles.verticalScrollbar, GUIStyles.background ); // Draw the link lines. if (Event.current.type == EventType.Repaint) { foreach (var node in _patch.nodeList) { if (!node.DrawLinkLines(_patch)) { // Request repaint if position info is not ready. Repaint(); break; } } } // Draw all the nodes and make the bounding box. BeginWindows(); foreach (var node in _patch.nodeList) { node.DrawWindowGUI(); _mainViewSize = Vector2.Max(_mainViewSize, node.windowPosition); } EndWindows(); // Place an empty box to expand the scroll view. GUILayout.Box( "", EditorStyles.label, GUILayout.Width(_mainViewSize.x + 256), GUILayout.Height(_mainViewSize.y + 128) ); // Draw working link line while wiring. if (_wiring != null) { DrawWorkingLink(); } EditorGUILayout.EndScrollView(); // Process all the feedback from the leaf UI elements. while (!FeedbackQueue.IsEmpty) { ProcessUIFeedback(FeedbackQueue.Dequeue()); } }
void DrawMainViewGUI() { _scrollPosition = EditorGUILayout.BeginScrollView(_scrollPosition, true, true); EditorGUILayout.BeginHorizontal(GUIStyles.background); GUILayout.FlexibleSpace(); var canvasRect = EditorGUILayout.BeginVertical(); GUILayout.FlexibleSpace(); //canvasRect.height -= 100; //var pivot = new Vector2(Screen.width / 2f, (Screen.height / 2f) + 50); //GUIUtility.ScaleAroundPivot(new Vector2(_zoom, _zoom), pivot); if (Event.current.button == 2 && Event.current.type == EventType.MouseDrag || Event.current.button == 0 && Event.current.type == EventType.MouseDrag && Event.current.modifiers == EventModifiers.Alt) { _scrollPosition += -Event.current.delta; Event.current.Use(); } if (Event.current.button == 1 && Event.current.type == EventType.MouseDown) { var menu = _nodeFactory.DrawMenu(_patch, Event.current.mousePosition); menu.DropDown(new Rect(Event.current.mousePosition, Vector2.one)); Event.current.Use(); } //canvasRect.y -= _scrollPosition.y; //canvasRect.x -= _scrollPosition.x; //GUIScaleUtility.BeginScale(ref canvasRect, pivot, 1 / _zoom, false); // Draw the link lines. if (Event.current.type == EventType.Repaint) { foreach (var node in _patch.nodeList) { if (!node.DrawLinkLines(_patch)) { // Request repaint if position info is not ready. Repaint(); break; } } } _mainViewMax = Vector2.zero; var mainViewMin = Vector2.one * 10000; // Draw all the nodes and make the bounding box. BeginWindows(); var h = 0f; foreach (var node in _patch.nodeList) { node.DrawWindowGUI(); _mainViewMax = Vector2.Max(_mainViewMax, node.windowPosition); mainViewMin = Vector2.Min(mainViewMin, node.windowPosition); h = Mathf.Max(h, node.LastRect.y); } _mainViewMax.x += 256; mainViewMin.x -= 50; mainViewMin.y -= 50; foreach (var node in _patch.nodeList) { node.windowPosition -= mainViewMin; } EndWindows(); var x = Mathf.Max(_mainViewMax.x * _zoom, Screen.width); var y = Mathf.Max((_mainViewMax.y + 128) * _zoom, Screen.height - 50); //Place an empty box to expand the scroll view. GUILayout.Box( "", GUIStyle.none, GUILayout.Width(x), GUILayout.Height(y)); // Draw working link line while wiring. if (_wiring != null) { DrawWorkingLink(); } //GUIScaleUtility.EndScale(); GUILayout.FlexibleSpace(); EditorGUILayout.EndVertical(); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndScrollView(); // Process all the feedback from the leaf UI elements. while (!FeedbackQueue.IsEmpty) { ProcessUIFeedback(FeedbackQueue.Dequeue()); } }