mirror of
https://github.com/DerTyp7/harvestdale-unity.git
synced 2025-10-30 13:07:10 +01:00
a
This commit is contained in:
@@ -1,33 +1,33 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
// using UnityEngine;
|
||||
// using UnityEngine.EventSystems;
|
||||
// using UnityEngine.UI;
|
||||
|
||||
public class DraggableSlotContentUI : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler
|
||||
{
|
||||
public int slotIndex; // slotIndex is set by SlotUI
|
||||
[HideInInspector] public Transform parentAfterDrag;
|
||||
public Image image;
|
||||
public void OnBeginDrag(PointerEventData eventData)
|
||||
{
|
||||
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;
|
||||
}
|
||||
// public class DraggableSlotContentUI : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler
|
||||
// {
|
||||
// public int slotIndex; // slotIndex is set by SlotUI
|
||||
// [HideInInspector] public Transform parentAfterDrag;
|
||||
// public Image image;
|
||||
// public void OnBeginDrag(PointerEventData eventData)
|
||||
// {
|
||||
// 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;
|
||||
// }
|
||||
|
||||
public void OnDrag(PointerEventData eventData)
|
||||
{
|
||||
Debug.Log("Dragging");
|
||||
transform.position = Input.mousePosition;
|
||||
// public void OnDrag(PointerEventData eventData)
|
||||
// {
|
||||
// Debug.Log("Dragging");
|
||||
// transform.position = Input.mousePosition;
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
public void OnEndDrag(PointerEventData eventData)
|
||||
{
|
||||
transform.SetParent(parentAfterDrag);
|
||||
image.raycastTarget = true;
|
||||
// invoke
|
||||
Inventory.OnPlayerInventoryChanged?.Invoke();
|
||||
}
|
||||
}
|
||||
// public void OnEndDrag(PointerEventData eventData)
|
||||
// {
|
||||
// transform.SetParent(parentAfterDrag);
|
||||
// image.raycastTarget = true;
|
||||
// // invoke
|
||||
// Inventory.OnPlayerInventoryChanged?.Invoke();
|
||||
// }
|
||||
// }
|
||||
Reference in New Issue
Block a user