Array index out of range means that you are trying to access a position in the array, that does not exist.
Put in some debug lines that check:
1. How big your array truthfully is
2. Where you are at in terms of accessing it.
// First, check how big the array truthfully is...
int a = prefabpool.Length;
You should note that even you have 7 items in your array as an example....
Then the array starts at 0 and ends at 6. Arrays always start at zero
print (a);
print (i); // Check which spot in the array you really are trying to use
↧