public void DrawNodeEditor(float _width, float _height) { panelSize = new Vector2(_width, _height); editorScrollPos = EditorGUILayout.BeginScrollView(editorScrollPos, false, false, GUILayout.Width(_width), GUILayout.Height(_height)); GUILayoutOption[] options = { GUILayout.Width(editorScrollSize.x), GUILayout.Height(editorScrollSize.y) }; EditorGUILayout.LabelField("", options); GUI.SetColor(new Color(25, 25, 25)); GUI.DrawTexture(new Rect(0, 0, _width, _height), Texture2D.blackTexture); GUI.SetColor(Color.white); if (Background != null) { for (var i = 0; i < 50; i++) { for (var j = 0; j < 25; j++) { Rect texRect = new Rect(i * Background.width, j * Background.height, Background.width, Background.height); GUI.DrawTexture(texRect, Background); } } } DrawEditorNodes(); LinksView.DrawLinks(); DrawIncompleteLink(); EditorGUILayout.EndScrollView(); editorScrollSize = new Vector2(farNodeX + 400, farNodeY + 400); nodeEditorSelection.Draw(Nodes.ToArray(), LinksView.GetLinks(), editorScrollPos); }
private void DrawBackgroundGrid(float _width, float _height) { if (Background != null) { //Background location based of current location allowing unlimited background //How many background are needed to fill the background var xCount = Mathf.Round(_width / Background.width) + 2; var yCount = Mathf.Round(_height / Background.height) + 2; //Current scroll offset for background var xOffset = Mathf.Round(GetCurrentScrollPosX() / Background.width) - 1; var yOffset = Mathf.Round(GetCurrentScrollPosY() / Background.height) - 1; var texRect = new Rect(0, 0, Background.width, Background.height); if (isInstance && constellationScript.IsDifferentThanSource) { GUI.SetColor(Color.yellow); } for (var i = xOffset; i < xOffset + xCount; i++) { for (var j = yOffset; j < yOffset + yCount; j++) { texRect.x = i * Background.width; texRect.y = j * Background.height; GUI.DrawTexture(texRect, Background); } } GUI.SetColor(Color.white); } }