This commit is contained in:
Janis
2023-02-22 13:50:33 +01:00
parent 13902bc589
commit a2e4459b5c
4 changed files with 6 additions and 10 deletions

View File

@@ -1,16 +1,18 @@
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class DraggableSlotContentUI : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler
{
public int slotIndex;
public int slotIndex; // slotIndex is set by SlotUI
[HideInInspector] public Transform parentAfterDrag;
public Image image;
public void OnBeginDrag(PointerEventData eventData)
{
Debug.Log("Start Drag");
parentAfterDrag = transform.parent;
slotIndex = parentAfterDrag.GetComponent<SlotUI>().slotIndex; // Set slotIndex again to be safe, but should be already set
transform.SetParent(transform.root);
transform.SetAsLastSibling();
image.raycastTarget = false;
@@ -25,7 +27,6 @@ public class DraggableSlotContentUI : MonoBehaviour, IBeginDragHandler, IDragHan
public void OnEndDrag(PointerEventData eventData)
{
Debug.Log("End drag");
transform.SetParent(parentAfterDrag);
image.raycastTarget = true;
// invoke