public static TweenPlayer MoveTo2(this Transform trans, Vector3 start, Vector3 target, float duration, AnimationCurve easeEquation, bool unscaled = false, LoopType loopType = LoopType.Restart, int loop = 1, Action onComplete = null) { var player = TweenPlayer.Gen(); TweenTrack track = new TweenTrack(); player.Add(track); Tween t = new Tween(); t.SetFromValue(start.x, start.y, start.z); t.SetToValue(target.x, target.y, target.z); player.SetDefaultTime(unscaled); t.SetEase(EaseEquation.Linear); t.SetLoop(loopType, loop); track.bindTarget = trans; t.SetValuesSetter((o, x, y, z, w) => { ((Transform)o).position = new Vector3(x, y, z); }); t.startTime = 0; t.SetDuration(duration); t.endTime = duration * loop; player.SetDuration(duration * loop); track.Add(t); player.Play(); return(player); }
public TweenPlayer Gen() { if (_abortPlayers.Count > 0) { var t = _abortPlayers[0]; _players.Add(t); _abortPlayers.RemoveAt(0); return(t); } else { var t = new TweenPlayer(); return(t); } }
public void Stop(TweenPlayer t) { switch (t.UpdateMode) { case TweenUpdateMode.Update: _runningPlayers.Remove(t); break; case TweenUpdateMode.Fixed: _runningPlayersFixUpdate.Remove(t); break; case TweenUpdateMode.Late: _runningPlayersLateUpdate.Remove(t); break; default: _runningPlayers.Remove(t); break; } }
public void Kill(TweenPlayer t) { switch (t.UpdateMode) { case TweenUpdateMode.Update: _runningPlayers.Remove(t); break; case TweenUpdateMode.Fixed: _runningPlayersFixUpdate.Remove(t); break; case TweenUpdateMode.Late: _runningPlayersLateUpdate.Remove(t); break; default: _runningPlayers.Remove(t); break; } _players.Remove(t); _abortPlayers.Add(t); }