public virtual void OnRenderAnchorConnection(T anchor, AnchorConnection connection) { if (connection.target == null || anchor.parent.parent != connection.target.parent.parent) { NodifyEditorUtilities.SafeDestroy(connection.gameObject); return; } Rect contentRect = GetContentRect(anchor); object targetRenderer = NodifyEditorUtilities.FindAnchorRenderer(connection.target.GetType()); if (targetRenderer != null) { Rect targetRect = (Rect)targetRenderer.GetType().GetMethod("GetContentRect").Invoke(targetRenderer, new object[] { connection.target }); Vector2 bezierStartPoint = contentRect.center; Vector2 bezierEndPoint = targetRect.center; float sizePercentage = 1f / NodifyEditorUtilities.currentSelectedGroup.editorZoomAmount; float lineSize = 2 * sizePercentage; NodifyEditorUtilities.DrawBezier(bezierStartPoint, bezierEndPoint, new Color(0, 0, 0, .25f), lineSize, 50); GUISkin skin = Resources.Load <GUISkin>("Styles/Nodify2EditorSkin"); GUIStyle minusButtonStyle = NodifyEditorUtilities.FindStyleByName(skin, "Node Anchor Remove"); GUIStyle connectionArrowStyle = NodifyEditorUtilities.FindStyleByName(skin, "Node Anchor Field Connection Arrow"); Vector2 centerPoint = NodifyEditorUtilities.PointOnBezier(bezierStartPoint, bezierEndPoint, .5f, 25); this.OnRenderAnchorConnectionMinusButton(anchor, connection, minusButtonStyle, connectionArrowStyle, centerPoint, bezierStartPoint, bezierEndPoint); } }
public virtual void OnRenderAnchorConnectionMinusButton(Anchor anchor, AnchorConnection connection, GUIStyle minusStyle, GUIStyle arrowStyle, Vector2 centerPoint, Vector2 start, Vector2 end) { Rect minusRect = new Rect(centerPoint.x - 8, centerPoint.y - 8, 16, 16); GUI.Box(minusRect, string.Empty, minusStyle); EditorGUIUtility.AddCursorRect(minusRect, MouseCursor.Link); if (minusRect.Contains(Event.current.mousePosition)) { if (Event.current.type == EventType.MouseDown && Event.current.button != 2) { anchor.RemoveConnection(connection); NodifyEditorUtilities.SafeDestroy(connection.gameObject); NodifyEditorWindow.ForceRepaint(); } } }
public void DrawAnchorConnection(AnchorConnection connection) { object renderer = Nodify.Editor.NodifyEditorUtilities.FindAnchorRenderer(connection.owner.GetType()); renderer.GetType().GetMethod("OnRenderAnchorConnection").Invoke(renderer, new object[] { connection.owner, connection }); }