How to destroy the first clone of a UI Image using an array every time I press a button?

Here is a line of code that I used inside the void Update() function to make clones of the UI Image “car”.

Image c = Instantiate (car, carPos, transform.rotation, transform.parent) as Image;

How do I store all the clones to an array and destroy the first one, every time I press a button?

If i use…Destroy(c); only the clone instantiated at that moment would be destroyed. But I want only the first clone to get destroyed. (each time I press the button)

Please help me fix this. Thanks in advance.

If you are going to be adding and removing things, I suggest that you use a list.


This will remove and destroy the first item in a list, if you add something to the list, it’s number will be equal to the current last item on the list plus one.