Browse Source

Fixed tooltip not hiding when parent was hidden or destroyed

James Peret 2 years ago
parent
commit
e11c61b138
2 changed files with 12 additions and 8 deletions
  1. 4 0
      Readme.md
  2. 8 8
      Runtime/Tooltips/TooltipTrigger.cs

+ 4 - 0
Readme.md

@@ -76,6 +76,10 @@ The UI package adds new functionality for designing game user interfaces and too
 
 ### Changelog
 
+#### v0.2.7
+- Fixed tooltip not hiding when parent was hidden or destroyed
+- Added an event trigger and get functions to encyclopedia
+
 #### v0.2.6
 - Added Selected Button component
 - Added Default Encyclopedia article and category

+ 8 - 8
Runtime/Tooltips/TooltipTrigger.cs

@@ -16,6 +16,8 @@ namespace KairoEngine.UI.Tooltips
         public string content;
         public string tooltipType = "";
         private bool visible = false;
+
+
         public void OnPointerEnter(PointerEventData eventData)
         {
             if(MouseInputUIBlocker.BlockedByUI) return;
@@ -29,13 +31,6 @@ namespace KairoEngine.UI.Tooltips
             
         }
 
-        public void OnPointerExit(PointerEventData eventData)
-        {
-            if(delay != null) LeanTween.cancel(delay.uniqueId);
-            TooltipSystem.Hide();
-            visible = false;
-        }
-
         public void OnMouseEnter()
         {
             if(MouseInputUIBlocker.BlockedByUI) return;
@@ -49,7 +44,12 @@ namespace KairoEngine.UI.Tooltips
             
         }
 
-        public void OnMouseExit()
+        public void OnPointerExit(PointerEventData eventData) => DisableTooltip();
+        public void OnMouseExit() => DisableTooltip();
+        private void OnDisable() => DisableTooltip();
+        private void OnDestroy() => DisableTooltip();
+
+        public void DisableTooltip()
         {
             if(delay != null) LeanTween.cancel(delay.uniqueId);
             TooltipSystem.Hide();