public virtual GUIStyle GetRenderStyle(T anchor) { GUISkin editorSkin = Resources.Load <GUISkin>("Styles/Nodify2EditorSkin"); switch (anchor.type) { case AnchorType.VARIABLE: if (anchor.exposedReference != null) { if (anchor.exposedReference.exposedType == ExposedType.FIELD) { return(NodifyEditorUtilities.FindStyleByName(editorSkin, "Node Anchor Field")); } if (anchor.exposedReference.exposedType == ExposedType.PROPERTY) { return(NodifyEditorUtilities.FindStyleByName(editorSkin, "Node Anchor Property")); } } break; case AnchorType.COMMENT: return(NodifyEditorUtilities.FindStyleByName(editorSkin, "Node Anchor Comment")); case AnchorType.METHOD: return(NodifyEditorUtilities.FindStyleByName(editorSkin, "Node Anchor Method")); } return(null); }
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 OnRenderNodeConnection(T anchor, NodeConnection connection) { if (connection.target == null || anchor.parent.parent != connection.target.parent) { NodifyEditorUtilities.SafeDestroy(connection.gameObject); return; } Rect contentRect = GetContentRect(anchor); object targetRenderer = NodifyEditorUtilities.FindNodeRenderer(connection.target.GetType()); if (targetRenderer != null) { Rect targetRect = (Rect)targetRenderer.GetType().GetMethod("GetContentRect").Invoke(targetRenderer, new object[] { connection.target }); Vector2 bezierStartPoint = NodifyEditorUtilities.ClosestPointOnRectangle(targetRect.center, contentRect); Vector2 bezierEndPoint = NodifyEditorUtilities.ClosestPointOnRectangle(bezierStartPoint, targetRect); if (anchor.type == AnchorType.METHOD) { Vector2 towardsStartCenter = (contentRect.center - bezierStartPoint).normalized; Vector2 towardsTargetCenter = (targetRect.center - bezierEndPoint).normalized; bezierStartPoint = new Vector2(bezierStartPoint.x + (towardsStartCenter.x * 10), bezierStartPoint.y + (towardsStartCenter.y * 10)); bezierEndPoint = new Vector2(bezierEndPoint.x + (towardsTargetCenter.x * 10), bezierEndPoint.y + (towardsTargetCenter.y * 10)); } Color bezierColor = Color.black; if (connection.state == ConnectionState.RUN) { bezierColor = Color.green; } if (connection.state == ConnectionState.ERROR) { bezierColor = Color.red; } float sizePercentage = 1f / NodifyEditorUtilities.currentSelectedGroup.editorZoomAmount; float lineSize = 2 * sizePercentage; NodifyEditorUtilities.DrawBezier(bezierStartPoint, bezierEndPoint, bezierColor, lineSize, Mathf.Abs(bezierEndPoint.y - bezierStartPoint.y) / 2); GUISkin skin = Resources.Load <GUISkin>("Styles/Nodify2EditorSkin"); GUIStyle minusButtonStyle = NodifyEditorUtilities.FindStyleByName(skin, "Node Anchor Remove"); GUIStyle connectionArrowStyle = NodifyEditorUtilities.FindStyleByName(skin, "Node Anchor Method Connection Arrow"); Vector2 centerPoint = NodifyEditorUtilities.PointOnBezier(bezierStartPoint, bezierEndPoint, .5f, Mathf.Abs(bezierEndPoint.y - bezierStartPoint.y) / 2); this.OnRenderNodeConnectionMinusButton(anchor, connection, minusButtonStyle, connectionArrowStyle, centerPoint, bezierStartPoint, bezierEndPoint); } }
public override GUIStyle GetRenderStyle(GlobalVariableBase node) { GUISkin editorSkin = Resources.Load <GUISkin>("Styles/Nodify2EditorSkin"); if (this.IsSelected(node)) { return(NodifyEditorUtilities.FindStyleByName(editorSkin, "Node Global Variable Selected")); } return(NodifyEditorUtilities.FindStyleByName(editorSkin, "Node Global Variable")); }
public override GUIStyle GetRenderStyle(NodeGroup node) { GUISkin editorSkin = Resources.Load <GUISkin>("Styles/Nodify2EditorSkin"); if (IsSelected(node)) { return(NodifyEditorUtilities.FindStyleByName(editorSkin, "Node Selected")); } return(NodifyEditorUtilities.FindStyleByName(editorSkin, "Node Group")); }
/// <summary> /// Returns the GUIStyle that is used to render the /// node on the graph. /// </summary> /// <param name="node"></param> /// <returns></returns> public virtual GUIStyle GetRenderStyle(T node) { GUISkin skin = Resources.Load <GUISkin>("Styles/Nodify2EditorSkin"); if (IsSelected(node)) { return(NodifyEditorUtilities.FindStyleByName(skin, "Node Selected")); } switch (node.editorExecutionState) { case ExecutionState.ERROR: return(NodifyEditorUtilities.FindStyleByName(skin, "Node Error")); default: return(NodifyEditorUtilities.FindStyleByName(skin, "Node")); } }
private void InitializeGUIStyles() { if (editorBreadcrumbLabel == null) { editorBreadcrumbLabel = NodifyEditorUtilities.FindStyleByName(guiSkin, "Editor Breadcrumb Label"); } if (editorBreadcrumbLabelCurrent == null) { editorBreadcrumbLabelCurrent = NodifyEditorUtilities.FindStyleByName(guiSkin, "Editor Breadcrumb Label Current"); } if (editorBackground == null) { editorBackground = NodifyEditorUtilities.FindStyleByName(guiSkin, "Editor Background"); } if (editorSelectionRect == null) { editorSelectionRect = NodifyEditorUtilities.FindStyleByName(guiSkin, "Editor Selection Rect"); } }