public void Add(InventoryLink link) { QbDb.InventoryLinks.InsertOnSubmit(link); }
public void OnPointerUp(PointerEventData eventData) { if (_item == null) { return; } List <RaycastResult> results = new List <RaycastResult>(); EventSystem.current.RaycastAll(eventData, results); InventorySlot targetSlot = null; DragNDropInventoryCanvas.Inventory inventory = null; foreach (var result in results) { if (null == targetSlot) { targetSlot = result.gameObject.GetComponent <InventorySlot>(); if (this == targetSlot) { targetSlot = null; } } if (null == inventory) { InventoryLink invLink = result.gameObject.GetComponent <InventoryLink>(); if (null != invLink) { inventory = invLink.Inventory; } } } if ((null != targetSlot) && targetSlot.CanAcceptItem(_item)) { if (!targetSlot.HasItem) { targetSlot.SetItem(_item); RemoveItem(); } else { TrySwap(targetSlot); } } else if (null != inventory) { if (_containingInventory != inventory) { if (inventory.TryAddItem(_item)) { RemoveItem(); } } } else if ((null != _containingInventory) && (null != _containingInventory.DropPoint)) { ItemData.SpawnItem(_item, _containingInventory.DropPoint.position, _containingInventory.DropPoint.rotation).AddComponent <Rigidbody>().useGravity = true; RemoveItem(); } BackToInital(); }