public void OnDrop(PointerEventData eventData) { eventData.pointerDrag.GetComponent <DragnDrop>().Changing = true; newParent = eventData.pointerDrag.GetComponent <DragnDrop>().Oldparent; oldSlot = newParent.GetComponent <Drop>().Slot; othersateCheck = newParent.GetComponent <SateCheck>(); storeItem = sateCheck.Slot.Item; storeOtherItem = eventData.pointerDrag; storeThisItem = sateCheck.ActiveItem; if (eventData.pointerDrag != null) { GameObject dragged = eventData.pointerDrag; if (sateCheck.Slot.Filled == false) { eventData.pointerDrag.transform.position = transform.position; eventData.pointerDrag.transform.SetParent(transform); sateCheck.Slot.Filled = true; sateCheck.ActiveItem = eventData.pointerDrag; othersateCheck.ActiveItem = null; othersateCheck.Slot.Filled = false; inventory.ItemChange(oldSlot, Slot, othersateCheck.Slot.Item); sateCheck.recieve(othersateCheck.Slot.Item); othersateCheck.give(); } else if (sateCheck.Slot.Filled == true) { storeOtherItem.transform.position = transform.position; storeOtherItem.transform.SetParent(transform); sateCheck.ActiveItem = storeOtherItem; storeThisItem.transform.position = newParent.position; storeThisItem.transform.SetParent(newParent); othersateCheck.ActiveItem = storeThisItem; inventory.ItemSwitch(oldSlot, Slot, othersateCheck.Slot.Item, sateCheck.Slot.Item); sateCheck.recieve(othersateCheck.Slot.Item); othersateCheck.recieve(storeItem); } } }
void Start() { sateCheck = gameObject.GetComponent <SateCheck>(); inventory = GetComponentInParent <Inventory>(); }
void Start() { sateCheck = GetComponentInParent <SateCheck>(); }