unity how to remove specific item from array code example
Example: unity how to remove specific item from array
int[] array;
void Update()
{
array = RemoveAt(3);
}
int[] RemoveAt(int at)
{
//convert
List<int> new_array = new List<int>();
for (int i = 0; i < array.Length; i++)
{
new_array.Add(array[i]);
}
//remove
new_array.RemoveAt(at);
//reconvert
int[] most_newest_array = new int[new_array.Count];
for (int i = 0; i < new_array.Count; i++)
{
most_newest_array[i] = new_array[i];
}
return most_newest_array;
}