I Am Working On My Game, Scurge Of The Shadows(Not Scourge Of The Shadows), And Have Stumbled Across A Problem. Its All Procedulary Generated, And I Keep The Doors the Player Can Go In In An Array. I Need To Clear The Array Every Time I Go In A Door With
OnTriggerEnter().
I Have Tried
Array.Clear(Array, 0, Array.Length);
And
Array.Resize(ref Array, 0);
Yet They Both Don’t Give Me The Desired Result Of A Null/Empty/Blank/Reset Array. Thanks Anyone Who Answers!
If you need an array to be null then just make it null.
int [] array = new int[10];
for (int i = 0 ; i< array.Length; i++){
array *= i;*
}
array = null; now your array is nothing. Trying to store something will result in a null reference exception. If you wish to set it all to 0 but keep the array: int [] array = new int[10]; for (int i = 0 ; i< array.Length; i++){ array = i; }
for (int i = 0 ; i< array.Length; i++){ array = 0; } What you do in the for loop depends on the type of your array. If you store object you can make it all null: GameObject array = new GameObject[10]; for (int i = 0 ; i< array.Length; i++){ array = null; }