summaryrefslogtreecommitdiff
path: root/Other/NodeEditorExamples/Assets/xNode-examples/Examples/RuntimeMathGraph/Scripts/Connection.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Other/NodeEditorExamples/Assets/xNode-examples/Examples/RuntimeMathGraph/Scripts/Connection.cs')
-rw-r--r--Other/NodeEditorExamples/Assets/xNode-examples/Examples/RuntimeMathGraph/Scripts/Connection.cs18
1 files changed, 18 insertions, 0 deletions
diff --git a/Other/NodeEditorExamples/Assets/xNode-examples/Examples/RuntimeMathGraph/Scripts/Connection.cs b/Other/NodeEditorExamples/Assets/xNode-examples/Examples/RuntimeMathGraph/Scripts/Connection.cs
new file mode 100644
index 00000000..ac4e889b
--- /dev/null
+++ b/Other/NodeEditorExamples/Assets/xNode-examples/Examples/RuntimeMathGraph/Scripts/Connection.cs
@@ -0,0 +1,18 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using XNode;
+
+namespace XNode.Examples.RuntimeMathNodes {
+ public class Connection : MonoBehaviour {
+ private RectTransform rectTransform;
+ public void SetPosition(Vector2 start, Vector2 end) {
+ if (!rectTransform) rectTransform = (RectTransform) transform;
+ transform.position = (start + end) * 0.5f;
+
+ float r = Mathf.Atan2(start.y - end.y, start.x - end.x) * Mathf.Rad2Deg;
+ transform.rotation = Quaternion.Euler(0, 0, r);
+ rectTransform.sizeDelta = new Vector2(Vector2.Distance(start, end), rectTransform.sizeDelta.y);
+ }
+ }
+} \ No newline at end of file