private void DrawNode(Node node) { NodeViewData viewData = this.GetViewDataForNode(node); Rect nodeRect = this.GetNodeRect(node); if (this.IsNodeSelected(node)) { Rect expandedNodeRect = RectUtil.Expand(nodeRect, kNodeSelectedLineWeight); GUIStyle nodeSelectedStyle = GUIStyleUtil.StyleWithTexture(GUI.skin.box, kNodeSelectedTexture); GUI.Box(expandedNodeRect, "", nodeSelectedStyle); } Rect nodeShadowRect = nodeRect; nodeShadowRect.position = nodeShadowRect.position + new Vector2(kNodeShadowOffset, kNodeShadowOffset); GUI.Box(nodeShadowRect, "", (GUIStyle)"NodeShadow"); GUIStyle nodeStyle = (GUIStyle)"Node"; if (this.TargetGraph.IsStartingNode(node)) { nodeStyle = (GUIStyle)"StartingNode"; } GUI.Box(nodeRect, viewData.name, nodeStyle); }
private void DrawGrid(Rect rect) { Vector2 offset = this._panner.Position; GUI.Box(rect, "", GUIStyleUtil.StyleWithTexture(kGridBackgroundTexture)); Color oldColor = Handles.color; int horizontalLinesOffset = Mathf.FloorToInt(offset.x / this._grid.LineSpacing); int verticalLinesOffset = Mathf.FloorToInt(offset.y / this._grid.LineSpacing); offset = new Vector2(Mathf.Repeat(offset.x, this._grid.LineSpacing), Mathf.Repeat(offset.y, this._grid.LineSpacing)); int numberOfVerticalLines = Mathf.CeilToInt(rect.width / this._grid.LineSpacing) + 1; int numberOfHorizontalLines = Mathf.CeilToInt(rect.height / this._grid.LineSpacing) + 1; for (float i = 0; i < numberOfVerticalLines; i++) { float x = i * this._grid.LineSpacing; x += offset.x - this._grid.LineSpacing; Handles.color = ((i - horizontalLinesOffset) % kSecondaryGridSpacing == 0) ? kDarkLineColor : kLightLineColor; Handles.DrawLine(new Vector3(x, 0.0f, 0.0f), new Vector3(x, rect.height, 0.0f)); } for (float i = 0; i < numberOfHorizontalLines; i++) { float y = i * this._grid.LineSpacing; y += offset.y - this._grid.LineSpacing; Handles.color = ((i - verticalLinesOffset) % kSecondaryGridSpacing == 0) ? kDarkLineColor : kLightLineColor; Handles.DrawLine(new Vector3(0.0f, y, 0.0f), new Vector3(rect.width, y, 0.0f)); } Handles.color = oldColor; }