public virtual void RemoveOutOfBoundsSegment(SegmentManager sm) { var d = 0f; do { GameObject oldest = sm.GetOldest(); if (oldest == null) { return; } float dist = 0f; dist = Mathf.Abs(oldest.transform.localPosition.z); if (dist > sm.removeDistance) { sm.EnqueuePool((sm.DequeueSpawned())); oldest.SetActive(false); } } while (d > sm.removeDistance); }