Files
ZHGD_Web/Assets/Scripts/UI/Other/HoverItem.cs

39 lines
1.0 KiB
C#
Raw Normal View History

2025-07-13 23:16:20 +08:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
using UnityEngine.EventSystems;
using System;
using UnityEngine.UI;
using TMPro;
public class HoverItem : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
{
public Action m_EnterAction;
public Action m_ExitAction;
private Tween m_Tween0;
private Tween m_Tween1;
public void OnPointerEnter(PointerEventData eventData)
{
m_Tween0.Kill();
//transform.transform.DOScale(1.2f, 0.3f);
m_Tween0 = GetComponent<Image>().DOFillAmount(1, .3f);
foreach (var ts in GetComponentsInChildren<TextMeshProUGUI>())
{
ts.fontSize *= 1.2f;
}
}
public void OnPointerExit(PointerEventData eventData)
{
m_Tween0.Kill();
//transform.DOScale(1f, 0.1f);
m_Tween0 = GetComponent<Image>().DOFillAmount(0, .1f);
foreach (var ts in GetComponentsInChildren<TextMeshProUGUI>())
{
ts.fontSize /= 1.2f;
}
}
}