40 lines
1.0 KiB
C#
40 lines
1.0 KiB
C#
|
|
using System.Collections;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using TMPro;
|
||
|
|
using UnityEngine;
|
||
|
|
using UnityEngine.EventSystems;
|
||
|
|
using Image = UnityEngine.UI.Image;
|
||
|
|
|
||
|
|
public class CardUI : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, IPointerClickHandler
|
||
|
|
{
|
||
|
|
public bool MountEventTrigger = true;
|
||
|
|
|
||
|
|
private Image card_image;
|
||
|
|
private TextMeshProUGUI card_text;
|
||
|
|
|
||
|
|
private Vector3 original_scale = Vector3.zero;
|
||
|
|
private const float scale_size = 1.2f;
|
||
|
|
|
||
|
|
private void Start()
|
||
|
|
{
|
||
|
|
card_image = GetComponent<Image>();
|
||
|
|
card_text = GetComponentInChildren<TextMeshProUGUI>();
|
||
|
|
original_scale = transform.localScale;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
public void OnPointerEnter(PointerEventData event_data)
|
||
|
|
{
|
||
|
|
transform.localScale = original_scale * scale_size;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void OnPointerExit(PointerEventData event_data)
|
||
|
|
{
|
||
|
|
transform.localScale = original_scale;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void OnPointerClick(PointerEventData event_data)
|
||
|
|
{
|
||
|
|
Debug.Log("Clicked" + card_text);
|
||
|
|
}
|
||
|
|
}
|