diff --git a/Assets/Prefabs/UI/TopRightButtons/ButtonSmallVariants/ButtonSmall_Camera.prefab b/Assets/Prefabs/UI/TopRightButtons/ButtonSmallVariants/ButtonSmall_Camera.prefab index 94b52c2f0..1bcee2958 100644 --- a/Assets/Prefabs/UI/TopRightButtons/ButtonSmallVariants/ButtonSmall_Camera.prefab +++ b/Assets/Prefabs/UI/TopRightButtons/ButtonSmallVariants/ButtonSmall_Camera.prefab @@ -164,6 +164,10 @@ PrefabInstance: type: 3} insertIndex: -1 addedObject: {fileID: 6093601054233314278} + - targetCorrespondingSourceObject: {fileID: 2664015473938025932, guid: b9565e5e6806aa84fa4bee3688c5cb46, + type: 3} + insertIndex: -1 + addedObject: {fileID: 7662381555634833805} m_SourcePrefab: {fileID: 100100000, guid: b9565e5e6806aa84fa4bee3688c5cb46, type: 3} --- !u!1 &5142072659738984082 stripped GameObject: @@ -183,7 +187,6 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: bc4e15ae4a4b42ffbe4bc9b862a15a6b, type: 3} m_Name: m_EditorClassIdentifier: - functionality: {fileID: 11400000, guid: ff7d5f7ae5009d24c869aa8086473845, type: 2} functionalities: - {fileID: 11400000, guid: ff7d5f7ae5009d24c869aa8086473845, type: 2} OnEnableFunctionality: @@ -216,3 +219,16 @@ MonoBehaviour: m_StringArgument: m_BoolArgument: 0 m_CallState: 2 +--- !u!114 &7662381555634833805 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5142072659738984082} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 452fb5315f90464b9b17bf47a7eecf82, type: 3} + m_Name: + m_EditorClassIdentifier: + tooltipText: Schermafbeelding maken diff --git a/Assets/Prefabs/UI/TopRightButtons/ButtonSmallVariants/ButtonSmall_Help.prefab b/Assets/Prefabs/UI/TopRightButtons/ButtonSmallVariants/ButtonSmall_Help.prefab index 82c77c09a..d3a32af89 100644 --- a/Assets/Prefabs/UI/TopRightButtons/ButtonSmallVariants/ButtonSmall_Help.prefab +++ b/Assets/Prefabs/UI/TopRightButtons/ButtonSmallVariants/ButtonSmall_Help.prefab @@ -19,6 +19,11 @@ PrefabInstance: value: objectReference: {fileID: 21300000, guid: c29dac6b4633ac14280b53b0720653df, type: 3} + - target: {fileID: 3093176464875961870, guid: b9565e5e6806aa84fa4bee3688c5cb46, + type: 3} + propertyPath: m_IsActive + value: 1 + objectReference: {fileID: 0} - target: {fileID: 5163534742322433831, guid: b9565e5e6806aa84fa4bee3688c5cb46, type: 3} propertyPath: m_Sprite @@ -174,6 +179,10 @@ PrefabInstance: type: 3} insertIndex: -1 addedObject: {fileID: 2480201083292398078} + - targetCorrespondingSourceObject: {fileID: 2664015473938025932, guid: b9565e5e6806aa84fa4bee3688c5cb46, + type: 3} + insertIndex: -1 + addedObject: {fileID: 5224959401776794096} m_SourcePrefab: {fileID: 100100000, guid: b9565e5e6806aa84fa4bee3688c5cb46, type: 3} --- !u!1 &8198138004752499479 stripped GameObject: @@ -193,3 +202,16 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 0cc2a0b73f53a7e428e9032e4ba70e79, type: 3} m_Name: m_EditorClassIdentifier: +--- !u!114 &5224959401776794096 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8198138004752499479} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 452fb5315f90464b9b17bf47a7eecf82, type: 3} + m_Name: + m_EditorClassIdentifier: + tooltipText: Informatie (opent in nieuw tabblad) diff --git a/Assets/Prefabs/UI/TopRightButtons/ButtonSmallVariants/ButtonSmall_Settings.prefab b/Assets/Prefabs/UI/TopRightButtons/ButtonSmallVariants/ButtonSmall_Settings.prefab index 15955ad6f..24bbb84a4 100644 --- a/Assets/Prefabs/UI/TopRightButtons/ButtonSmallVariants/ButtonSmall_Settings.prefab +++ b/Assets/Prefabs/UI/TopRightButtons/ButtonSmallVariants/ButtonSmall_Settings.prefab @@ -328,6 +328,10 @@ PrefabInstance: type: 3} insertIndex: -1 addedObject: {fileID: 5612239837602820538} + - targetCorrespondingSourceObject: {fileID: 2664015473938025932, guid: b9565e5e6806aa84fa4bee3688c5cb46, + type: 3} + insertIndex: -1 + addedObject: {fileID: 7173424971446478480} m_SourcePrefab: {fileID: 100100000, guid: b9565e5e6806aa84fa4bee3688c5cb46, type: 3} --- !u!224 &2409698041119019074 stripped RectTransform: @@ -427,3 +431,16 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: configuration: {fileID: 11400000, guid: ef4fdd9a7713bc0458843a4884b6e1c5, type: 2} +--- !u!114 &7173424971446478480 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8222931090793477828} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 452fb5315f90464b9b17bf47a7eecf82, type: 3} + m_Name: + m_EditorClassIdentifier: + tooltipText: Instellingen diff --git a/Assets/Scripts/UI/Components/TooltipDialog.cs b/Assets/Scripts/UI/Components/TooltipDialog.cs index 6dba48a4b..561cb960c 100644 --- a/Assets/Scripts/UI/Components/TooltipDialog.cs +++ b/Assets/Scripts/UI/Components/TooltipDialog.cs @@ -1,3 +1,4 @@ +using DG.Tweening; using System; using System.Collections; using TMPro; @@ -14,7 +15,11 @@ public class TooltipDialog : MonoBehaviour private TextMeshProUGUI tooltiptext; private RectTransform rectTransform; + private RectTransform lastTarget; + private RectTransform currentTarget; private ContentSizeFitter contentSizeFitter; + private Sequence animationSequence; + private const float animationDuration = 0.25f; private Vector3[] worldCorners = new Vector3[4]; #region Singleton @@ -49,39 +54,29 @@ private void Awake() private void FollowPointer() { rectTransform.position = Mouse.current.position.ReadValue(); - - SwapPivot(); } - private void SwapPivot() + public void AlignOnElement(RectTransform element) { - var pivot = Vector2.zero; - //Swap pivot based on place in screen (to try to stay in the screen horizontally) - if (rectTransform.position.x + GetRectTransformBounds(rectTransform).size.x > Screen.width) - { - pivot.x = 1; - } - - //Swap pivot based on place in screen (to try to stay in the screen vertically) - if (rectTransform.position.y + GetRectTransformBounds(rectTransform).size.y > Screen.height) - { - pivot.y = 1; - } + if (!element) return; - rectTransform.pivot = pivot; + lastTarget = currentTarget; + currentTarget = element; } - public void AlignOnElement(RectTransform element) + private void UpdatePosition() { - if (!element) return; - - var elementCenter = GetRectTransformBounds(element).center; - var elementMax = GetRectTransformBounds(element).max; + var elementCenter = GetRectTransformBounds(currentTarget).center; + var elementMax = GetRectTransformBounds(currentTarget).max; + var elementMin = GetRectTransformBounds(currentTarget).min; + Vector2 tooltipSize = GetRectTransformBounds(rectTransform).size; + Vector2 elementSize = GetRectTransformBounds(currentTarget).size; + + var tooltipPosition = new Vector2(elementMax.x + offset.x, elementCenter.y + offset.y); + if (currentTarget.position.x > Screen.width * 0.5f) + tooltipPosition = new Vector2(elementMin.x - tooltipSize.x - offset.x, elementCenter.y + offset.y); - var tooltipPosition = new Vector2(elementMax.x, elementCenter.y) + offset; rectTransform.position = tooltipPosition; - - SwapPivot(); } public void ShowMessage(string message = "Tooltip", RectTransform hoverTarget = null) @@ -96,6 +91,8 @@ public void ShowMessage(string message = "Tooltip", RectTransform hoverTarget = tooltiptext.text = message; StartCoroutine(FitContent()); + + StartAnimation(1f); } private IEnumerator FitContent() @@ -106,8 +103,11 @@ private IEnumerator FitContent() } public void Hide() - { - gameObject.SetActive(false); + { + StartAnimation(0f, ()=> { + if(lastTarget == currentTarget || currentTarget == null) + gameObject.SetActive(false); + }); } private Bounds GetRectTransformBounds(RectTransform transform) @@ -121,5 +121,33 @@ private Bounds GetRectTransformBounds(RectTransform transform) return bounds; } + + + private void StartAnimation(float targetScale, Action onFinish = null) + { + // If the animation is playing, quickly complete it and then start a new one + if (animationSequence != null && animationSequence.IsPlaying()) + { + animationSequence.Complete(true); + } + animationSequence = CreateAnimationSequence(targetScale, onFinish); + animationSequence.Play(); + } + + private Sequence CreateAnimationSequence(float scale, Action onFinish = null) + { + Sequence sequence = DOTween.Sequence(rectTransform); + sequence.SetEase(scale > 0 ? Ease.OutBounce : Ease.InBack); + sequence.Join(rectTransform.DOScale(scale, scale > 0 ? animationDuration : 0.5f * animationDuration).OnUpdate(() => UpdatePosition())); + + // Ensure animation sequence is nulled after completing to clean up + sequence.OnComplete(() => + { + onFinish?.Invoke(); + animationSequence = null; + }); + + return sequence; + } } } \ No newline at end of file diff --git a/Assets/Textures/UI/Icons/Icon_Help.png b/Assets/Textures/UI/Icons/Icon_Help.png index a6ea79d25..eb5a97553 100644 --- a/Assets/Textures/UI/Icons/Icon_Help.png +++ b/Assets/Textures/UI/Icons/Icon_Help.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b314df9bd11d0a1b824d1867a811859e1b08b18b5cfd87b88ff520a625c46efb -size 12191 +oid sha256:3b7004219e723db389c30bf8c4dda3029039e8b7f2f8b7dc8d87b9866fdff3a7 +size 8644