How Add items to List

Hi
I have the problem when drag the items to other inventory i want to save in one List the objects but i can’t because not Add nathing to list.
This my function when have a problem:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

public class Inventory : MonoBehaviour, IHasChangedPlace {
    [SerializeField] Transform slots;
    public List<GameObject> itemsList;

    // Use this for initialization

    void Start () {
        itemsList = new List<GameObject>();
        HasChangedPlace ();
         // Inicializa a lista de Objectos
    }
       

    public void HasChangedPlace(){
       
   
        foreach (Transform slotTransform in slots) {
           

            GameObject item = slotTransform.GetComponent<Slot> ().item;
            if (item) {
                //GameObject moveDown = slotTransform.GetComponent<Slot> ().item;
                Debug.Log (item.name);

                itemsList.Add (item);
            }
        }
    }
}


namespace UnityEngine.EventSystems{
    public interface IHasChangedPlace: IEventSystemHandler{
        void HasChangedPlace ();
}
}

“This my function when have a problem:”

So which part has a problem?
Does your Debug.Log print item name in your for loop?
Do you see your item in your List when your game starts?
Are you sure your objects are actually children of slots tTansform?
Are you sure your objects have Slot component added, and item is not null?

Instead of guessing, it is best to debug.

Add Debug.Logs to every possible location and see where your code or logic fails.

And why do you call your method “HasChangedPlace” when you are actually only filling a List with GameObjects?

Did you follow some tutorial perhaps?

BTW - this question belongs to scripting forum, it is not a 2D specific question.