Z
Z
Zimaell2020-10-25 13:08:56
Unity
Zimaell, 2020-10-25 13:08:56

Why is the object not being destroyed?

this is how the object appears on the scene

[SerializeField] private Dictionary<int, Cell> Cells = new Dictionary<int, Cell>();
..........
Cells[Num] = Instantiate(Prefab, new Vector3(x, y, 0), Quaternion.identity) as Cell;
Cells[Num].transform.parent = gameObject.transform;
Cells[Num].name = "Test";
++Num;

further in another method of the same class, I want to delete it
Debug.Log(Num);
Destroy(Cells[Num]);

in debugging, the number is displayed correctly, but the object still remains on the stage, it is not deleted, why is that?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
freeExec, 2020-10-25
@Zimaell

You are deleting the component Cell, but you must delete GameObjectto remove the object from the scene.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question