public void DrawNodeCurveDotted(Vector3 startPos, Vector3 endPos, Color color) { Handles.BeginGUI(); Handles.color = color; //Handles.DrawAAPolyLine(3f, new Vector3[] { startPos, endPos }); var space = 5f; var length = 10f; var ray = new Ray(startPos, (endPos - startPos).normalized); var fullDistance = Vector3.Distance(endPos, startPos); var width = 2f; width /= FlowSystem.GetZoom(); for (float distance = 0f; distance < fullDistance; distance += space) { var pos = ray.GetPoint(distance); distance += length; if (distance > fullDistance) { distance = fullDistance; } var toPos = ray.GetPoint(distance); Handles.DrawAAPolyLine(width, new Vector3[] { pos, toPos }); } Handles.EndGUI(); }
public void DrawCap(Vector3 pos, Vector3 startPos, Vector3 endPos, Quaternion rot, Color shadowColor, Color lineColor) { if (FlowSystem.GetZoom() < 1f) { return; } if (this.arrow == null) { this.arrow = Resources.Load <Texture2D>("UI.Windows/Flow/Arrow"); } var size = 12f; size /= FlowSystem.GetZoom(); //pos = this.editor.zoomDrawer.ConvertScreenCoordsToZoomCoords(pos, topLeft: true); var scrollPos = -FlowSystem.GetScrollPosition(); var offset = -8f; if (this.editor.scrollRect.Contains(new Vector3(pos.x - scrollPos.x + FlowSystemEditorWindow.SETTINGS_WIDTH + offset, pos.y - scrollPos.y + FlowSystemEditorWindow.TOOLBAR_HEIGHT + offset, 0f)) == false) { return; } var shadowOffset = Vector3.one * 1f; shadowOffset.z = 0f; var v1 = startPos - endPos; v1.x = -v1.x; var v2 = Vector3.left; var angle = Mathf.Atan2( Vector3.Dot(Vector3.back, Vector3.Cross(v1, v2)), Vector3.Dot(v1, v2)) * Mathf.Rad2Deg; var oldColor = GUI.color; GUI.color = shadowColor; GUIExt.DrawTextureRotated(new Rect(pos.x - size * 0.5f + shadowOffset.x, pos.y - size * 0.5f + shadowOffset.y, size, size), arrow, -angle + 180f); GUI.color = lineColor; GUIExt.DrawTextureRotated(new Rect(pos.x - size * 0.5f, pos.y - size * 0.5f, size, size), arrow, -angle + 180f); GUI.color = oldColor; /*Handles.color = shadowColor; * Handles.ConeCap(-1, pos + shadowOffset, rot, 15f); * Handles.color = lineColor; * Handles.ConeCap(-1, pos, rot, 15f);*/ }
public void DrawNodeCurve(Vector3 startPos, Vector3 endPos, Color color) { var shadowColor = new Color(0f, 0f, 0f, 0.5f); var lineColor = color; //new Color(1f, 1f, 1f, 1f); var shadowOffset = Vector3.one * 1f; shadowOffset.z = 0f; var width = 3f; width /= FlowSystem.GetZoom(); Handles.BeginGUI(); Handles.color = shadowColor; Handles.DrawAAPolyLine(width, new Vector3[] { startPos + shadowOffset, endPos + shadowOffset }); Handles.color = lineColor; Handles.DrawAAPolyLine(width, new Vector3[] { startPos, endPos }); var ray = new Ray(startPos, (endPos - startPos).normalized); var rot = Quaternion.LookRotation(endPos - startPos); var every = DRAW_EVERY_ARROW; var fullDistance = Vector3.Distance(endPos, startPos); if (fullDistance < every * 2f) { var pos = ray.GetPoint(fullDistance * 0.5f); this.DrawCap(pos, startPos, endPos, rot, shadowColor, lineColor); //var arrow = (new GUIStyle("StaticDropdown")).normal.background; //GUIExt.DrawTextureRotated(pos, arrow, Vector3.Angle(startPos, endPos)); } else { for (float distance = every; distance < fullDistance; distance += every) { var pos = ray.GetPoint(distance); this.DrawCap(pos, startPos, endPos, rot, shadowColor, lineColor); //var arrow = (new GUIStyle("StaticDropdown")).normal.background; //GUIExt.DrawTextureRotated(pos, arrow, rot); } } Handles.EndGUI(); }
public string DrawComponentCurve(Vector3 startPos, Vector3 endPos, Color color, float stopDistance, string label) { var shadowColor = new Color(0f, 0f, 0f, 0.5f); var lineColor = color; //new Color(1f, 1f, 1f, 1f); var shadowOffset = Vector3.one * 2f; shadowOffset.z = 0f; var ray = new Ray(startPos, (endPos - startPos).normalized); var rot = Quaternion.LookRotation(endPos - startPos); var centerPoint = (startPos + endPos) * 0.5f; endPos = ray.GetPoint(stopDistance); var fullDistance = Vector3.Distance(endPos, startPos); var width = 4f; width /= FlowSystem.GetZoom(); Handles.BeginGUI(); Handles.color = shadowColor; Handles.DrawSolidDisc(startPos + shadowOffset, Vector3.back, 5f); Handles.color = lineColor; Handles.DrawSolidDisc(startPos, Vector3.back, 5f); Handles.color = shadowColor; Handles.DrawAAPolyLine(width, new Vector3[] { startPos + shadowOffset, endPos + shadowOffset }); Handles.color = lineColor; Handles.DrawAAPolyLine(width, new Vector3[] { startPos, endPos }); var labelStyle = new GUIStyle(GUI.skin.label); labelStyle.stretchWidth = false; var backOverStyle = new GUIStyle("flow node 0"); backOverStyle.stretchWidth = false; backOverStyle.stretchHeight = false; var backStyle = new GUIStyle("flow node hex 5"); var style = new GUIStyle(GUI.skin.textField); style.stretchWidth = true; style.stretchHeight = true; style.wordWrap = true; //style.contentOffset = new Vector2(0f, -15f); style.contentOffset = new Vector2(0f, 5f); style.alignment = TextAnchor.MiddleCenter; style.border = backStyle.border; style.normal = backStyle.normal; style.focused = backStyle.normal; style.active = backStyle.normal; style.hover = backStyle.normal; var content = new GUIContent(label); var contentRect = GUILayoutUtility.GetRect(content, labelStyle); contentRect.width = Mathf.Max(contentRect.width, 40f); contentRect.width += 40f; contentRect.height += 20f; centerPoint.x -= contentRect.width * 0.5f; centerPoint.y -= contentRect.height * 0.5f; var boxRect = new Rect(centerPoint.x, centerPoint.y, contentRect.width, contentRect.height); style.fixedWidth = contentRect.width; // + 20f; style.fixedHeight = contentRect.height; var boxRectBack = boxRect; backOverStyle.fixedWidth = style.fixedWidth; backOverStyle.fixedHeight = style.fixedHeight + 10f; var oldColor = GUI.backgroundColor; var bColor = color; bColor.a = 0.4f; GUI.backgroundColor = bColor; GUI.Box(boxRectBack, "Test", backOverStyle); GUI.backgroundColor = oldColor; label = GUI.TextField(boxRect, label, style); var every = DRAW_EVERY_ARROW; if (fullDistance < every * 2f) { var pos = ray.GetPoint(fullDistance * 0.5f); this.DrawCap(pos, startPos, endPos, rot, shadowColor, lineColor); //var arrow = (new GUIStyle("StaticDropdown")).normal.background; //GUIExt.DrawTextureRotated(pos, arrow, Vector3.Angle(startPos, endPos)); } else { for (float distance = every; distance < fullDistance; distance += every) { var pos = ray.GetPoint(distance); this.DrawCap(pos, startPos, endPos, rot, shadowColor, lineColor); //var arrow = (new GUIStyle("StaticDropdown")).normal.background; //GUIExt.DrawTextureRotated(pos, arrow, rot); } } Handles.EndGUI(); return(label); }