I can not see the object when re Instantiate

Hi everyone!
I create images in the interface.
But after I delete them and create knitted they are not recreated.
Checking “if (slotik == null) print(“not work”);” it does not work, but they do not appear in the hierarchy, although the first time are no problem.

public void ReInventory(string _pack)
{
    int q = 0;
    for (int i = 0; i < invent.Count; i++)
    {
        if (invent*.pack == _pack)*

{
GameObject slotik = Instantiate(g.itemContainer) as GameObject;
if (slotik == null) print(“not work”);
slotik.GetComponent().id = i; slotik.transform.SetParent(g.inventory.transform.FindChild(invent*.pack).GetChild(q).transform);*
q += 1;
slotik.name = invent_.slotName; slotik.transform.localScale = Vector3.one; slotik.gameObject.GetComponent().sprite = Resources.Load(invent*.iconka);
}
}
}*

I definitely got it wrong, please help out :slight_smile:_

I simplify all scripts in one and repeated the mistake. By clicking on the button “I” or “TAB” removed all the objects and create again, normal work and create “slot1” and “slot2”, but does not create them “slotInst”! What’s wrong?

And the first time it is created, and the second time nothing is created and the hierarchy is empty … nonsense …

public class test : MonoBehaviour
{
    public GameObject panel;
    public Transform slot;
    public GameObject slotInst;
    public GameObject slot1;
    public GameObject slot2;

    void Update ()
    {
        if (Input.GetKeyUp(KeyCode.I) || Input.GetKeyUp(KeyCode.Tab))
        {
            if (panel.activeSelf)
            {
                panel.SetActive(false);
            }
            else
            {
                panel.SetActive(true);
                SortInvent();
            }
        }
    }

    void SortInvent()
    {
        for (int i = 0; i < panel.transform.childCount; i++)
        {
            Destroy(panel.transform.GetChild(i).gameObject);
        }

        GameObject slot01 = Instantiate(slot1) as GameObject;
        slot01.transform.SetParent(panel.transform);
        GameObject slot02 = Instantiate(slot2) as GameObject;
        slot02.transform.SetParent(panel.transform);
        GameObject slotik = Instantiate(slotInst) as GameObject;
        slotik.transform.SetParent(panel.transform.FindChild("ItemContainer(Clone)"));
    }
}