using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; public class DropZone : MonoBehaviour, IDropHandler, IPointerEnterHandler, IPointerExitHandler { public int slotIndex; public DraggableCard currentCard; private Image image; void Awake() { image = GetComponent(); } public void OnDrop(PointerEventData eventData) { DraggableCard card = eventData.pointerDrag?.GetComponent(); if (card == null) return; if (currentCard != null && currentCard != card) currentCard.ReturnToOriginal(); currentCard = card; card.transform.SetParent(transform); card.GetComponent().anchoredPosition = Vector2.zero; } public void OnPointerEnter(PointerEventData eventData) { if (image != null) image.color = new Color(1f, 1f, 1f, 0.5f); } public void OnPointerExit(PointerEventData eventData) { if (image != null) image.color = new Color(1f, 1f, 1f, 0.2f); } public void SetCorrect() { if (image != null) image.color = new Color(0f, 1f, 0f, 0.5f); } public void SetWrong() { if (image != null) image.color = new Color(1f, 0f, 0f, 0.5f); } public void ResetColor() { if (image != null) image.color = new Color(1f, 1f, 1f, 0.2f); currentCard = null; } }