/// <summary> /// Sub function for dropping item (subcode function for <see cref="OnDrop(PointerEventData)"/> and <see cref="OnDisable"/>. /// </summary> private void DropItemSubFunc() { // Drop the item ItemStack dropItemStack = this.SlotRenderer.CorrespondingInventory.InventorySlots[this.SlotRenderer.CorrespondingInventorySlotID].CurrentItemStack; this.SlotRenderer.CorrespondingInventory.InventorySlots[this.SlotRenderer.CorrespondingInventorySlotID].CurrentItemStack = null; Debug.Log("Dropping itemstack: " + dropItemStack); Vector3 dropPos = Vector3.zero; Transform playerTransform = GameObject.FindGameObjectsWithTag("Player").Select(o => o.transform).FirstOrDefault(); if (playerTransform == null) { Debug.Log("No player found to drop the itemstack at!"); return; } dropPos = playerTransform.position; if (dropItemStack == null) { return; } dropItemStack.CreateEntity(dropPos); }