private async Task Spawner(float time, CancellationToken token) { while (!token.IsCancellationRequested) { //wait time await UniTask.Delay(TimeSpan.FromSeconds(time), cancellationToken : token); //get a ball from the pool var ball = _pooler.Pop(); //not null? if (ball) { //initialize ball ball.Initialize(); //change position ball.transform.position = _spawner.position; // Subscribe to HasCollided ReactiveProperty ball.HasCollided.Subscribe(collided => { //if true send it back into the pool if (collided) { _pooler.Push(ball); } }); if (_uiManager.PoolWidget) { _uiManager.PoolWidget.UpdateWidgetValue(_pooler.SizeLimit, _pooler.ActiveElements); } } } }