예제 #1
0
    public void BacktoPrviousPosition()
    {
        if (transform.parent == itemDraggerParent)
        {
            transform.position = startPosition;
            transform.SetParent(startParent);

            //recreate the connections just like in the ondrop function

            InventorySlot slot = gameObject.GetComponentInParent <InventorySlot>();
            if (slot)
            {
                slot.AddItemToInventory();
                if (slot.GetComponentInChildren <FoodDisplay>())
                {
                    slot.GetComponentInChildren <FoodDisplay>().EnableBackFrame();
                    slot.ResetTransform();
                }
            }

            CrafterSlot crafterSlot = gameObject.GetComponentInParent <CrafterSlot>();
            if (crafterSlot)
            {
                crafterSlot.AddToFoodCrafter();
                if (crafterSlot.GetComponentInChildren <FoodDisplay>())
                {
                    crafterSlot.GetComponentInChildren <FoodDisplay>().EnableBackFrame();
                    crafterSlot.ResetTransform();
                }
            }
        }
    }