summaryrefslogtreecommitdiff
path: root/Other/NodeEditorExamples/Assets/xNode-examples/Examples/RuntimeMathGraph/Scripts/UGUITooltip.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Other/NodeEditorExamples/Assets/xNode-examples/Examples/RuntimeMathGraph/Scripts/UGUITooltip.cs')
-rw-r--r--Other/NodeEditorExamples/Assets/xNode-examples/Examples/RuntimeMathGraph/Scripts/UGUITooltip.cs45
1 files changed, 45 insertions, 0 deletions
diff --git a/Other/NodeEditorExamples/Assets/xNode-examples/Examples/RuntimeMathGraph/Scripts/UGUITooltip.cs b/Other/NodeEditorExamples/Assets/xNode-examples/Examples/RuntimeMathGraph/Scripts/UGUITooltip.cs
new file mode 100644
index 00000000..fd61a329
--- /dev/null
+++ b/Other/NodeEditorExamples/Assets/xNode-examples/Examples/RuntimeMathGraph/Scripts/UGUITooltip.cs
@@ -0,0 +1,45 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using UnityEngine.UI;
+
+namespace XNode.Examples.RuntimeMathNodes {
+ public class UGUITooltip : MonoBehaviour {
+ public CanvasGroup group;
+ public Text label;
+ private bool show;
+ private RuntimeMathGraph graph;
+
+ private void Awake() {
+ graph = GetComponentInParent<RuntimeMathGraph>();
+ }
+
+ private void Start() {
+ Hide();
+ }
+
+ private void Update() {
+ if (show) UpdatePosition();
+ }
+
+ public void Show() {
+ show = true;
+ group.alpha = 1;
+ UpdatePosition();
+ transform.SetAsLastSibling();
+ }
+
+ public void Hide() {
+ show = false;
+ group.alpha = 0;
+ }
+
+ private void UpdatePosition() {
+ Vector2 pos;
+ RectTransform rect = graph.scrollRect.content.transform as RectTransform;
+ Camera cam = graph.gameObject.GetComponentInParent<Canvas>().worldCamera;
+ RectTransformUtility.ScreenPointToLocalPointInRectangle(rect, Input.mousePosition, cam, out pos);
+ transform.localPosition = pos;
+ }
+ }
+} \ No newline at end of file