CapersProject/Assets/UltimateCleanGUIPack/Common/Scripts/Core/Tooltip.cs
2024-06-04 03:26:03 +09:00

46 lines
1.3 KiB
C#

// Copyright (C) 2015-2021 gamevanilla - All rights reserved.
// This code can only be used under the standard Unity Asset Store End User License Agreement.
// A Copy of the Asset Store EULA is available at http://unity3d.com/company/legal/as_terms.
using UnityEngine;
using UnityEngine.EventSystems;
namespace UltimateClean
{
/// <summary>
/// Basic tooltip component used in the kit.
/// </summary>
public class Tooltip : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
{
public GameObject tooltip;
public float fadeTime = 0.1f;
public virtual void OnPointerEnter(PointerEventData eventData)
{
if (eventData.button != PointerEventData.InputButton.Left)
{
return;
}
if (tooltip != null)
{
StartCoroutine(Utils.FadeIn(tooltip.GetComponent<CanvasGroup>(), 1.0f, fadeTime));
}
}
public virtual void OnPointerExit(PointerEventData eventData)
{
if (eventData.button != PointerEventData.InputButton.Left)
{
return;
}
if (tooltip != null)
{
StartCoroutine(Utils.FadeOut(tooltip.GetComponent<CanvasGroup>(), 0.0f, fadeTime));
}
}
}
}