private void RenderLink(string description, StateEditorGUI fromState, StateEditorGUI toState, float edgeFraction) { Rect fromStateRect = GetScreenRect(fromState.GetBounds()); Rect toStateRect = GetScreenRect(toState.GetBounds()); Vector3 startPos = new Vector3(fromStateRect.x + fromStateRect.width * edgeFraction, fromStateRect.y + fromStateRect.height - StateEditorGUI.kShadowSize - 1.0f, 0); Vector3 endPos = new Vector3(Mathf.Round(toStateRect.x + toStateRect.width / 2.0f) + 0.5f, Mathf.Round(toStateRect.y - kArrowHeight - 1.0f) + 0.5f, 0); Vector3 startTangent = startPos + Vector3.up * 50.0f; Vector3 endTangent = endPos - Vector3.up * 50.0f; Handles.BeginGUI(); Handles.color = _style._linkColor; Handles.DrawBezier(startPos, endPos, startTangent, endTangent, _style._linkColor, EditorUtils.BezierAATexture, 2f); Handles.DrawAAConvexPolygon(new Vector3[] { new Vector3(endPos.x, endPos.y + kArrowHeight, 0.0f), new Vector3(endPos.x + kArrowWidth, endPos.y, 0.0f), new Vector3(endPos.x - kArrowWidth, endPos.y, 0.0f) }); Handles.EndGUI(); Vector2 textSize = _style._linkTextStyle.CalcSize(new GUIContent(description)); float lineFraction = edgeFraction; Rect labelPos = new Rect(startPos.x + ((endPos.x - startPos.x) * lineFraction) - (textSize.x * 0.5f), startPos.y + ((endPos.y - startPos.y) * lineFraction) - (textSize.y * 0.5f), textSize.x, textSize.y); //Draw shadow EditorUtils.DrawColoredRoundedBox(new Rect(labelPos.x + StateEditorGUI.kShadowSize, labelPos.y + StateEditorGUI.kShadowSize, labelPos.width, labelPos.height), new Color(0.0f, 0.0f, 0.0f, 0.35f)); //Draw white background EditorUtils.DrawColoredRoundedBox(labelPos, _style._linkDescriptionColor); Color origColor = GUI.backgroundColor; GUI.backgroundColor = Color.clear; GUI.Label(labelPos, description, _style._linkTextStyle); GUI.backgroundColor = origColor; }
private Vector3 GetLinkStartPosition(StateEditorGUI state, int linkIndex = 0) { float fraction = 1.0f / (state.GetEditableObject().GetEditorLinks().Length + 1.0f); float edgeFraction = fraction * (1 + linkIndex); Rect stateRect = GetScreenRect(state.GetBounds()); return(new Vector3(Mathf.Round(stateRect.x + stateRect.width * edgeFraction), Mathf.Round(stateRect.y + stateRect.height - StateEditorGUI.kShadowSize - 1.0f), 0)); }
private Vector3 GetLinkEndPosition(StateEditorGUI state, int linkIndex = 0) { Rect stateRect = GetScreenRect(state.GetBounds()); return(new Vector3(Mathf.Round(stateRect.x + stateRect.width / 2.0f) + 0.5f, Mathf.Round(stateRect.y - kArrowHeight - 1.0f) + 0.5f, 0)); }