public void Update() { if (Input.GetKeyDown(KeyCode.Space)) { SpawnExplosion(new Vector2(Screen.width * 0.5f, Screen.height * 0.5f)); } if (Input.GetMouseButtonDown(0)) { SpawnExplosion(Input.mousePosition); } // When any explosions have finished, return them to the pool. for (var i = m_activeExplosions.Count - 1; i >= 0; i--) { var explosion = m_activeExplosions[i]; if (!explosion.IsAlive) { m_activeExplosions.RemoveAt(i); m_explosionPool.ReturnObject(explosion); } } }