public void ForceStop() { ps.Stop(); ps.Clear(); if (pool != null) { pool.Return(this); } }
public void Return() { //Recycle the object only if the pool is still alive if (pool) { pool.Return(this); } }
protected void DrawTimeIndicators(Rect container) { float z = Mathf.Max(1f, Zoom); int zoomScaling = (int)((int)(z / secondsPerTick) * secondsPerTick) + 1; int ticks = (int)((BaseDuration) / secondsPerTick) * zoomScaling; float offset = Offset * container.width * Zoom; int accents = ticks / ticksPerAccent; while (currentIndicators.Count < accents) { currentIndicators.Add(indicatorPool.Retrieve()); } if (currentIndicators.Count >= accents) { List <TimeSliderIndicator> toReturn = new List <TimeSliderIndicator>(); int toRemove = currentIndicators.Count - accents; for (int i = 0; i < toRemove; ++i) { toReturn.Add(currentIndicators[currentIndicators.Count - 1]); indicatorPool.Return(currentIndicators[currentIndicators.Count - 1]); currentIndicators.RemoveAt(currentIndicators.Count - 1); } } for (int i = 0; i < currentIndicators.Count; ++i) { TimeSliderIndicator indicator = currentIndicators[i]; float t = Mathf.Clamp01(i / (float)accents); float x = t * container.width * Zoom - offset; indicator.UpdateData(BaseDuration * t, x); } }