private void Update() { if (EdgeTriggersTracker.HasData()) { Repaint(); } }
static void DrawEdge(Edge edge, Vector2Int indexes, Color color) { var p1 = GetPositionAsFromSlot(edge.fromSlot, indexes.x); var p2 = GetPositionAsToSlot(edge.toSlot, indexes.y); DrawEdge(p1, p2, color * edge.color, EdgeTriggersTracker.GetTimings(edge)); }
static void DrawEdge(Graphs.Edge edge, Color color) { var p1 = GetPositionAsFromSlot(edge.fromSlot); var p2 = GetPositionAsToSlot(edge.toSlot); DrawEdge(p1, p2, color * edge.color, EdgeTriggersTracker.GetTimings(edge)); }
public void PopulateEdges() { foreach (var outSlot in outputSlots) { List <EventCall> outCalls = _runtimeInstance.Outputs.FindAll(call => call.EventName == outSlot.name); foreach (EventCall call in outCalls) { var targetNode = graph[call.Receiver.GetInstanceID().ToString()]; var inSlot = targetNode[call.MethodFullPath]; if (!graph.Connected(outSlot, inSlot)) { Edge edge = graph.Connect(outSlot, inSlot); call.OnTriggered += (() => EdgeTriggersTracker.RegisterTrigger(edge)); } } } }
public void PopulateEdges() { foreach (var outSlot in outputSlots) { List <EventCall> outCalls = _runtimeInstance.Outputs.FindAll(call => call.eventShortName == outSlot.name); foreach (EventCall call in outCalls) { var targetNode = graph[call.receiver.GetInstanceID().ToString()]; var inSlot = targetNode[call.MethodFullPath]; if (graph.Connected(outSlot, inSlot)) { Edge existingEdge = graph.edges.Find(e => e.fromSlot == outSlot && e.toSlot == inSlot); graph.RemoveEdge(existingEdge); } Edge edge = graph.Connect(outSlot, inSlot); call.OnTriggered += (() => EdgeTriggersTracker.RegisterTrigger(edge, call)); } } }
private static void DrawConnection(EventCall ev, Bezier b) { const float tangentSize = 50; float diff = b.end.x - b.start.x; diff = Mathf.Sign(diff) * Mathf.Min(Mathf.Abs(diff), tangentSize); var p1 = b.start; var p2 = b.end; var p3 = p1; var p4 = p2; if (b.startTangent == Bezier.Tangent.Auto) { p3 += new Vector2(diff, 0); } else if (b.startTangent == Bezier.Tangent.Negative) { p3 -= new Vector2(Math.Abs(diff), 0); } else if (b.startTangent == Bezier.Tangent.Positive) { p3 += new Vector2(Math.Abs(diff), 0); } else if (b.startTangent == Bezier.Tangent.NegativeUnscaled) { p3 -= new Vector2(tangentSize, 0); } else if (b.startTangent == Bezier.Tangent.PositiveUnscaled) { p3 += new Vector2(tangentSize, 0); } if (b.endTangent == Bezier.Tangent.Auto) { p4 -= new Vector2(diff, 0); } else if (b.endTangent == Bezier.Tangent.Negative) { p4 -= new Vector2(Math.Abs(diff), 0); } else if (b.endTangent == Bezier.Tangent.Positive) { p4 += new Vector2(Math.Abs(diff), 0); } else if (b.endTangent == Bezier.Tangent.NegativeUnscaled) { p4 -= new Vector2(tangentSize, 0); } else if (b.endTangent == Bezier.Tangent.PositiveUnscaled) { p4 += new Vector2(tangentSize, 0); } Color c = ev.color; Color prevColor = Handles.color; Handles.color = c; Handles.DrawBezier(p1, p2, p3, p4, c, (Texture2D)UnityEditor.Graphs.Styles.selectedConnectionTexture.image, EdgeGUI.kEdgeWidth); foreach (var trigger in EdgeTriggersTracker.GetTimings(ev)) { Vector3 pos = EdgeGUI.CalculateBezierPoint(trigger, p1, p3, p4, p2); Handles.DrawSolidArc(pos, Vector3.back, pos + Vector3.up, 360, EdgeGUI.kEdgeWidth); } Handles.color = prevColor; }