private void DrawBoxSelection() { Rect r = CanvasUtility.WorldToCanvasRect(canvas.boxSelection, canvas.canvasState); GUI.color = BehaviourEditorStyles.BOX_SELECTION_COLOUR; GUI.DrawTexture(r, new Texture2D(5, 5)); Handles.color = BehaviourEditorStyles.BOX_SELECTION_OUTLINE_COLOUR; Handles.DrawLine(new Vector3(r.min.x, r.min.y, 0), new Vector3(r.max.x, r.min.y, 0)); Handles.DrawLine(new Vector3(r.max.x, r.min.y, 0), new Vector3(r.max.x, r.max.y, 0)); Handles.DrawLine(new Vector3(r.min.x, r.max.y, 0), new Vector3(r.max.x, r.max.y, 0)); Handles.DrawLine(new Vector3(r.min.x, r.min.y, 0), new Vector3(r.min.x, r.max.y, 0)); }
/* * public void DrawBounds () { * if (canvas.ghostGroup == null) * return; * * // draw start group bounds * GUI.color = new Color (1, 1, 1, 0.07f); * * if (canvas.canvasState.groups == null) * return; * * // draw all other groups' bounds * for (int i = 0; i < canvas.canvasState.groups.Count; i++) { * Rect r = CanvasUtility.WorldToCanvasRect(canvas.canvasState.groups [i].transform.rect, canvas.canvasState); * GUI.Box (r, ""); * } * } */ public void DrawNodePanel(NodePanel panel) { // draw the backgorund Color bgColour = panel.bgColour; bgColour.a = panel.alpha; if (canvas.selectedPanels.Contains(panel)) { bgColour += BehaviourEditorStyles.nodeSelected_BgColour; } GUI.color = bgColour; Rect rect = CanvasUtility.WorldToCanvasRect(panel.transform.rect, canvas.canvasState); GUI.Box(rect, ""); int padding = -5; int iconSize = 40; // draw the icon Color contentColour = panel.contentColour; contentColour.a = panel.alpha; GUI.color = contentColour; Rect iconRect = new Rect((rect.width - iconSize) / 2 + rect.x, (rect.height - iconSize) / 2 + rect.y, iconSize, iconSize); //iconRect.width = rect.height; GUI.DrawTexture(iconRect, panel.icon); // draw the label GUIStyle labelStyle = new GUIStyle(); labelStyle.alignment = TextAnchor.MiddleCenter; RectOffset paddedLabelRect = new RectOffset(padding, padding, padding / 2, 0); Rect labelRect = paddedLabelRect.Add(rect); labelRect.height = 20; string label = BehaviourEditor.debugView ? panel.guid.ToString().Substring(panel.guid.ToString().Length - 3) : panel.label; GUI.Label(labelRect, label, BehaviourEditor.defaultSkin.label); GUI.color = panel.Parent == null ? new Color(1, 1, 1, 0.2f) : new Color(1, 1, 1, 1); GUI.DrawTexture(CanvasUtility.WorldToCanvasRect(panel.inHandle.transform.rect, canvas.canvasState), BehaviourEditorStyles.handle); if (panel.outHandle != null && panel.hasOuthandle) { GUI.color = panel.Children.Count > 0 || canvas.previewConnection != null && canvas.previewConnection._start.Parent == panel.outHandle.transform ? new Color(1, 1, 1, 1) : new Color(1, 1, 1, 0.2f); GUI.DrawTexture(CanvasUtility.WorldToCanvasRect(panel.outHandle.transform.rect, canvas.canvasState), BehaviourEditorStyles.handle); } if (BehaviourEditor.debugView) { GUI.color = Color.red; Rect anchorRect = new Rect(panel.transform.position, Vector2.one); GUI.Box(CanvasUtility.WorldToCanvasRect(anchorRect, canvas.canvasState), "x"); anchorRect = new Rect(panel.inHandle.transform.position, Vector2.one); } }