Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.EventSystems;
- public class ItemSlot : MonoBehaviour, IDropHandler
- {
- public GameObject Item
- {
- get
- {
- if (transform.childCount > 0)
- {
- return transform.GetChild(0).gameObject;
- }
- return null;
- }
- }
- public void OnDrop(PointerEventData eventData)
- {
- //if there is not item already then set our item.
- if (!Item)
- {
- SoundManager.Instance.PlaySound(SoundManager.Instance.dropItemSound);
- DragDrop.itemBeingDragged.transform.SetParent(transform);
- DragDrop.itemBeingDragged.transform.localPosition = new Vector2(0, 0);
- if (!transform.CompareTag("QuickSlot"))
- {
- DragDrop.itemBeingDragged.GetComponent<InventoryItem>().isInsideQuickSlots = false;
- InventorySystem.Instance.ReCalculateList();
- }
- if (transform.CompareTag("QuickSlot"))
- {
- DragDrop.itemBeingDragged.GetComponent<InventoryItem>().isInsideQuickSlots = true;
- InventorySystem.Instance.ReCalculateList();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement