How do I pick up an item and add it to my inventory?

How do I pick up an item and add it to my inventory? I am making a 2D Top down, game and I have my scene and player set up. I want to be able to walk over to a pile of wood pick it up and add it to my inventory.

I have a collider on both the player and the game object but how do I go about scripting this?

here’s what i’m using. just call this function, modified however you like, and remove the game object that represents the item in the scene when you click and are in range (or a collision occurs, however you want to do it):

public void Inv_Add(Item item, int qnty)
        {
            var found = -1;
            bool fullflag = false;

            if (item.objname == "Nothing")
                return;

            for (var i = 0; i < invcapacity; i++)
            {
                    if (inventory[i].item.objname == item.objname)
                    {
                        found = i; //We affect to found the place of the item if we find it
                        break;
                    }
            }

            //If it doesn't exist

            if (found == -1)
            {
                //Let's check if there is an empty place to add our item
                for (var j = 0; j < invcapacity; j++)
                {
                    if (inventory[j].item.objname == "Nothing")
                    {
                        found = j;
                        break;
                    }
                    else if (j == (invcapacity - 1) && found != j)
                    {
                        fullflag = true;
                        break;
                    }
                }
            }