I
I
Ilya Garbazhiy2020-02-26 14:26:03
2D
Ilya Garbazhiy, 2020-02-26 14:26:03

How to remove an object from an array in Unity 2D?

I have a list with three objects. They are destroyed, but empty spaces remain in the array. Please help, or remove cells from the array, thus reducing its length, or instead of ARRAY.Lenth, find out the number of only filled elements.

PS For me, in Unity, arrays and lists are the same, in this context I mean that it is set something like this: public GameObject[] enemies;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
#
#, 2020-02-26
@mindtester

What type (class) are you talking about?
ps Ilya Garbazhiy ,

GameObjects[]
according to the rules of the C# language, this is an array . dynamic resizing is not provided
pps advice - use a list. and it is worth exploring the differences

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question