-
Notifications
You must be signed in to change notification settings - Fork 0
/
ItemSlot.cs
32 lines (28 loc) · 898 Bytes
/
ItemSlot.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using System.Collections;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.EventSystems;
public class ItemSlot : MonoBehaviour, IDropHandler
{
public int correctItem;
public bool isCorrectItemPlaced = false;
public void OnDrop(PointerEventData eventData)
{
Debug.Log("OnDrop");
if (eventData.pointerDrag != null)
{
eventData.pointerDrag.GetComponent<RectTransform>().anchoredPosition = GetComponent<RectTransform>().anchoredPosition;
}
DragDrop draggedItem = eventData.pointerDrag.gameObject.GetComponent<DragDrop>();
if (draggedItem.objectNum == correctItem)
{
Debug.Log("Correct item placed!");
isCorrectItemPlaced = true;
}
else
{
Debug.Log("Incorrect item placed.");
isCorrectItemPlaced = false;
}
}
}