Supermarket.Hand.Pickup C# (CSharp) Method

Pickup() public method

public Pickup ( IPickupable target ) : void
target IPickupable
return void
        public void Pickup(IPickupable target)
        {
            // Drop carried thing so new thing can be picked up
            if (Carrying)
            {
                Drop();
            }
            else
            {
                // If not carrying, hand will be disabled so need to enable it
                Enable();
            }

            // Position will be the position of last Drop() so need to move to cursor again -> otherwise, won't move til next update
            MoveToCursor();

            held = target;
            previousParent = target.gameObject.transform.parent;            // Remember previous parent so hierarchy can be restored on Drop()
            held.gameObject.transform.position = transform.position;        // Set object as child and match position
            held.gameObject.transform.parent = transform;
            held.OnPickUp();
        }

Same methods

Hand::Pickup ( IPickupable held, System.Action OnDrop ) : void
Hand::Pickup ( IPickupable held, System.Action OnDrop, System.Action OnCancel ) : void