From 0f3cfcc364c094eab6b8519ff7c0c36a2e70214e Mon Sep 17 00:00:00 2001 From: BOT Alex <44818698+MagicBOTAlex@users.noreply.github.com> Date: Sun, 21 Apr 2024 06:36:44 +0200 Subject: [PATCH] Extra tooltip exit collider --- Assets/Prefabs/UI/GameUI.prefab | 5 +++++ Assets/Scripts/UI/UITooltips.cs | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/Assets/Prefabs/UI/GameUI.prefab b/Assets/Prefabs/UI/GameUI.prefab index 8bc10aa..cbaaeef 100644 --- a/Assets/Prefabs/UI/GameUI.prefab +++ b/Assets/Prefabs/UI/GameUI.prefab @@ -934,6 +934,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: tooltip: {fileID: 7959461870474528235} + ExtraExitCollider: {fileID: 3164206115851743815} ButtonIndex: -1 --- !u!1 &1444386719009988973 GameObject: @@ -1667,6 +1668,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: tooltip: {fileID: 8584771696634545955} + ExtraExitCollider: {fileID: 3164206115851743815} ButtonIndex: -1 --- !u!1 &3452371300238378862 GameObject: @@ -3072,6 +3074,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: tooltip: {fileID: 2899067781696711495} + ExtraExitCollider: {fileID: 3164206115851743815} ButtonIndex: -1 --- !u!1 &5621856367784821633 GameObject: @@ -3950,6 +3953,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: tooltip: {fileID: 4502190811754076786} + ExtraExitCollider: {fileID: 3164206115851743815} ButtonIndex: -1 --- !u!1 &8438906130455969465 GameObject: @@ -4546,6 +4550,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: tooltip: {fileID: 1475988817490299594} + ExtraExitCollider: {fileID: 3164206115851743815} ButtonIndex: -1 --- !u!1001 &1148800059794808287 PrefabInstance: diff --git a/Assets/Scripts/UI/UITooltips.cs b/Assets/Scripts/UI/UITooltips.cs index b7b3318..f589f19 100644 --- a/Assets/Scripts/UI/UITooltips.cs +++ b/Assets/Scripts/UI/UITooltips.cs @@ -10,6 +10,7 @@ public class UITooltips : MonoBehaviour // Not optimal but gamejam momento [SerializeField] private GameObject tooltip; + [SerializeField] private EventTrigger ExtraExitCollider; private EventTrigger uiEvents; public int ButtonIndex = -1; @@ -29,6 +30,12 @@ public class UITooltips : MonoBehaviour pointerEnter.callback.AddListener((data) => { OnEnter((PointerEventData)data); }); uiEvents.triggers.Add(pointerEnter); + // Subscribe to PointerEnter event + EventTrigger.Entry ExtraExitEnter = new EventTrigger.Entry(); + ExtraExitEnter.eventID = EventTriggerType.PointerEnter; + ExtraExitEnter.callback.AddListener((data) => { OnExit((PointerEventData)data); }); + ExtraExitCollider.triggers.Add(ExtraExitEnter); + // Subscribe to PointerExit event EventTrigger.Entry pointerExit = new EventTrigger.Entry(); pointerExit.eventID = EventTriggerType.PointerExit;