Hey there,
i have some issuce with my garbage collection, so i have some questions,
1:
is it better to do this:
for (int x = 0; x < List1.GetLength(0); x++) {
for (int y = 0; y < List1.GetLength(1); y++) {
List1[x, y] = null; // or new MyType()
}
}
than that:
List1= new MyType[50, 50];
2:
is it better to do this:
Vector2 vec = new Vector2();
void Update () {
vec.x = 3;
vec.y = 5;
Funktion(vec);
}
Than that:
void Update () {
Funktion(new Vector2(3,5));
}
And how to solve this in a better way:
public IEnumerator SpawnEnemys(int count, GameObject enemy) {
int counter = 0;
while (counter < count) {
yield return new WaitForSeconds(Random.Range(5f, 10f));
Instantiate(enemy, transform.position, Quaternion.identity);
counter++;
}
}
First thanks for that nice answer :) 1: thanks i will look at object pooling :) 3: i dont mean the wait for seconds i mean the Instantiate, it created a lot of gcallocated..., but i think i can do this with object pooling too ^^
– TheSorm