/// <summary> /// Constructor /// </summary> /// <param name="originalController">The InventoryController this item originated from</param> /// <param name="originPoint">The point inside the inventory from which this item originated from</param> /// <param name="item">The item-instance that is being dragged</param> /// <param name="offset">The starting offset of this item</param> public DraggedItem( InventoryController originalController, Vector2Int originPoint, IInventoryItem item, Vector2 offset) { OriginalController = originalController; CurrentController = OriginalController; OriginPoint = originPoint; Item = item; _offset = offset; // Create an image representing the dragged item _image = new GameObject("DraggedItem").AddComponent <Image>(); _image.raycastTarget = false; _image.transform.SetParent(originalController.gameObject.GetComponentInParent <Canvas>().transform); _image.transform.SetAsLastSibling(); _image.transform.localScale = Vector3.one; _image.sprite = item.Sprite; _image.SetNativeSize(); }