public override void Update() { foreach (var t in _times.Keys.ToList()) { _times[t] -= Time.deltaTime; } foreach (var t in animated) { t.Translate(_directions[t] * Time.deltaTime * _speed); } animated.RemoveWhere((x) => { if (_times[x] <= 0) { _directions.Remove(x); _times.Remove(x); OnEnd[x]?.Invoke(x); OnEnd.Remove(x); return(true); } else { return(false); } }); }
public override void Update() { foreach (var t in animated) { t.position = Vector3.MoveTowards(t.position, _to, Time.deltaTime * _speed); } IEnumerable <Transform> finished = animated.Where((x) => x.position == _to); foreach (var e in finished) { OnEnd[e]?.Invoke(e); OnEnd.Remove(e); } animated.RemoveWhere((x) => x.position == _to); }