public EventCall(Object sender, Object receiver, string eventShortName, string eventFullName, string methodName, UnityEventBase unityEvent) { this.sender = sender as Component ? (sender as Component).gameObject : sender; this.receiver = receiver as Component ? (receiver as Component).gameObject : receiver; this.eventShortName = eventShortName; this.eventFullName = eventFullName; method = methodName; color = EdgeGUI.ColorForIndex(this.eventShortName); this.unityEvent = unityEvent; UpdateReceiverComponentName(receiver); AttachTrigger(unityEvent); }
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; }