public void OnBeginDrag(PointerEventData eventData) { currentObject = this; currentObject.GetTransform().SetParent(emptyParent); currentObject.GetTransform().SetAsFirstSibling(); startSlot = currentObject.GetCurrentSlot(); }
public bool AddInventoryObject(InventoryObject inventoryObject, bool isSpecial = false) { InventoryUISlot nextFreeSlot; // get next free slot if (isSpecial && slotSpecial.IsEmpty()) { nextFreeSlot = slotSpecial; } else { nextFreeSlot = GetNextFreeSlot(inventoryObject.GetCurrentPos()); } if (nextFreeSlot != null) { // create new inventory ui object from template GameObject templateClone = Instantiate(inventoryUIObjectTemplate.gameObject, Vector3.zero, Quaternion.identity); templateClone.SetActive(true); templateClone.name = inventoryObject.GetTitle(); // link it with the slot InventoryUIObject newInventoryUIObject = templateClone.GetComponent <InventoryUIObject>(); newInventoryUIObject.SetInventoryObject(inventoryObject); newInventoryUIObject.SetCurrentSlot(nextFreeSlot); newInventoryUIObject.GetTransform().localScale = inventoryUIObjectTemplate.GetTransform().localScale; nextFreeSlot.Init(this); return(true); } return(false); }