Answers for "unity how to remove specific item from array"

C#
0

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;
    }
Posted by: Guest on March-09-2021

Code answers related to "unity how to remove specific item from array"

C# Answers by Framework

Browse Popular Code Answers by Language