public Tween(TweenFunction tweeningFunction, int duration, Action <double> stepAction, Action?completeAction) { Duration = duration; TweeningFunction = tweeningFunction; Step += (sender, e) => stepAction(e.Amount); Complete += (sender, e) => completeAction?.Invoke(); }
/// <summary> /// Position tweening animation /// </summary> /// <param name="callback"></param> /// <returns></returns> IEnumerator UpdatePosition(System.Action <bool> callback) { float tweenDuration; EasingFunction.Ease tweenFunction; if (segmentEnabled) { tweenDuration = tweenInDuraction; tweenFunction = tweenEaseInFunction; } else { tweenDuration = tweenOutDuraction; tweenFunction = tweenEaseOutFunction; } for (float elaspedTime = 0.0f; elaspedTime <= tweenDuration; elaspedTime += Time.deltaTime) { float progress = elaspedTime / tweenDuration; float easeExpression = EasingFunction.GetEasingFunction(tweenFunction)(0.0f, 1.0f, progress); transform.position = Vector3.LerpUnclamped(previousPosition, targetPosition, easeExpression); yield return(null); } transform.position = targetPosition; yield return(null); callback(true); }
public static Audio.Handle FadeIn(string sound, bool looped, float duration, TweenFunction function = null, float volume = -1) { #if !NOAUDIO if (!HasAudio) { return(default(Audio.Handle)); } sound = sound.Trim().ToLower(); if (function == null) { function = TweenFunctions.Linear; } var info = Audio.Instance.audiolist[sound]; var handle = Play(sound, 0.00001f); if (handle == null || !handle.Success) { return(handle); } handle.Instance.IsLooped = looped; handle.FadeState = 1; handle.FadeDuration = handle.FadeTimer = duration; handle.FadeFunction = function; handle.FadeVolume = Audio.Volume(volume, info); return(handle); #else return(default(Audio.Handle)); #endif }
private void Awake() { if (instance == null) { instance = this; } }
public static Set StepFunction(TweenFunction function, float time, EaseType ease, System.Action endAction = null, float delay = 0f) { Set set = new Set("Instant Step Clip", endAction); set.Track(1).AddStepFunction(function, time, ease, null); set.Play(); return(set); }
public FunctionClip AddStepFunction(TweenFunction func, float time, EaseType ease, System.Action endAction = null) { FunctionClip functionClip = new FunctionClip(this, func, time, ease, endAction); mClips.Add(functionClip); Register(functionClip); return(functionClip); }
public void OnKeyPress(Key key) { if (functions.ContainsKey(key)) { Window.Title = $"TweenTest - Fps: {Time.Fps} - {functionNames[key]}"; f = functions[key]; } }
public void Construct(double start, double end, double time, TweenFunction tweenF) { _distance = end - start; _original = start; _current = start; _totalDuration = time; _tweenF = tweenF; }
public void Construct(float start, float end, float time, TweenFunction tweenF) { _distance = end - start; _original = start; _current = start; _totalDuration = time; _tweenF = tweenF; }
public Tween(double start, double end, double time, TweenFunction tweenF) { distance = end - start; original = start; current = start; totalDuration = time; this.tweenF = tweenF; }
//Construct 记录了补间的初始值、最终值和执行补间操作的时间,可传入一个补间函数来确定只随时间如何变化 public void Construct(double start, double end, double time, TweenFunction tweenF) { _distance = end - start; _original = start; //_original是初始值 _current = start; _totalDuration = time; //总共的维持时间 _tweenF = tweenF; }
public static TweenOperation Create(TweenFunction function, float duration) { var state = new State() { function = function }; return(TweenAction <State> .Prepare(state, new TweenOptions(duration))); }
public UITweener(Vector2 positionOut, TweenState state, float tween, TweenFunction functionIn, float speedIn, TweenFunction functionOut, float speedOut) { this.positionOut = positionOut; this.state = state; this.tween = tween; this.functionIn = functionIn; this.functionOut = functionOut; this.speedIn = speedIn; this.speedOut = speedOut; }
public static void FadeOutAll(float duration, TweenFunction function = null) { if (function == null) { function = TweenFunctions.Linear; } for (int i = Audio.Instance.handles.Count - 1; i >= 0; --i) { Sound.FadeOut(Audio.Instance.handles[i], duration, function); } }
public void AddTween(float length, TweenFunction tweenFunction) { tween t = new tween(); t.length = length; t.startTime = Time.time; t.tweenFunction = tweenFunction; t.done = false; tweens.Add(t); }
public void MoveTo(float fromValue, float toValue, float time, TweenFunction func, iTween.EaseType ease) { Vector3 pos = transform.position; pos.x = fromValue; transform.position = pos; _toValue = toValue; iTween.MoveTo(gameObject, iTween.Hash("x", toValue, "time", time, "easeType", ease, "oncomplete", "onTweenComplete", "oncompletetarget", gameObject)); eventFunction = func; }
public void MoveTo(float fromValue, float toValue, float time, TweenFunction func, iTween.EaseType ease) { Vector3 pos = transform.position; pos.x = fromValue; transform.position = pos; _toValue = toValue; iTween.MoveTo(gameObject, iTween.Hash("x", toValue, "time", time, "easeType", ease, "oncomplete", "onTweenComplete", "oncompletetarget", gameObject)); eventFunction = func; }
public UITweener(Vector2 positionOut, TweenState state, TweenFunction function, float speed) : this(positionOut, state, 0, function, speed, function, speed) { switch (state) { case TweenState.TweeningOut: case TweenState.In: tween = 0; break; case TweenState.TweeningIn: case TweenState.Out: tween = 1; break; } }
public FunctionClip(RedTween.Track track, TweenFunction function, float time, EaseType ease, System.Action end) { if (function == null) { return; } mTrack = track; mTime = time; mFunctionTween = function; mEndAction = end; mType = RedTweenType.Function; mFunction = Easing.EaseFunction(ease); if (mFunction != null) { mInitialized = true; } }
public static void FadeOut(Audio.Handle handle, float duration, TweenFunction function = null) { if (handle == null) { return; } #if !NOAUDIO if (function == null) { function = TweenFunctions.Linear; } handle.FadeState = -1; handle.FadeDuration = handle.FadeTimer = duration; handle.FadeFunction = function; handle.FadeVolume = handle.Instance.Volume; #endif }
public static Tween Animate(TweenFunction f, int duration, Expression <Func <Color> > property, Color finalValue, Action?completeAction = null) { var s = _setter(property, (double t, Color initialValue) => initialValue.Merge(finalValue, t)); return(Start(f, duration, s, completeAction)); }
public Tween(double start, double end, double time, TweenFunction tweenF) { Construct(start, end, time, tweenF); }
public Tween(float start, float end, float time, TweenFunction tweenF) { Construct(start, end, time, tweenF); }
private void AffectFunctions() { switch (TweenType) { case Tween.Linear: _tweenFunction = TweenFunctions.Linear; break; case Tween.InQuad: _tweenFunction = TweenFunctions.InQuad; break; case Tween.OutQuad: _tweenFunction = TweenFunctions.OutQuad; break; case Tween.InOutQuad: _tweenFunction = TweenFunctions.InOutQuad; break; case Tween.OutInQuad: _tweenFunction = TweenFunctions.OutInQuad; break; case Tween.InCubic: _tweenFunction = TweenFunctions.InCubic; break; case Tween.OutCubic: _tweenFunction = TweenFunctions.OutCubic; break; case Tween.InOutCubic: _tweenFunction = TweenFunctions.InOutCubic; break; case Tween.OutInCubic: _tweenFunction = TweenFunctions.OutInCubic; break; case Tween.InQuart: _tweenFunction = TweenFunctions.InQuart; break; case Tween.OutQuart: _tweenFunction = TweenFunctions.OutQuart; break; case Tween.InOutQuart: _tweenFunction = TweenFunctions.InOutQuart; break; case Tween.OutInQuart: _tweenFunction = TweenFunctions.OutInQuart; break; case Tween.InQuint: _tweenFunction = TweenFunctions.InQuint; break; case Tween.OutQuint: _tweenFunction = TweenFunctions.OutQuint; break; case Tween.InOutQuint: _tweenFunction = TweenFunctions.InOutQuint; break; case Tween.OutInQuint: _tweenFunction = TweenFunctions.OutInQuint; break; case Tween.InSine: _tweenFunction = TweenFunctions.InSine; break; case Tween.OutSine: _tweenFunction = TweenFunctions.OutSine; break; case Tween.InOutSine: _tweenFunction = TweenFunctions.InOutSine; break; case Tween.OutInSine: _tweenFunction = TweenFunctions.OutInSine; break; case Tween.InExpo: _tweenFunction = TweenFunctions.InExpo; break; case Tween.OutExpo: _tweenFunction = TweenFunctions.OutExpo; break; case Tween.InOutExpo: _tweenFunction = TweenFunctions.InOutExpo; break; case Tween.OutInExpo: _tweenFunction = TweenFunctions.OutInExpo; break; case Tween.InCirc: _tweenFunction = TweenFunctions.InCirc; break; case Tween.OutCirc: _tweenFunction = TweenFunctions.OutCirc; break; case Tween.InOutCirc: _tweenFunction = TweenFunctions.InOutCirc; break; case Tween.OutInCirc: _tweenFunction = TweenFunctions.OutInCirc; break; case Tween.InElastic: _tweenFunction = TweenFunctions.InElastic; break; case Tween.OutElastic: _tweenFunction = TweenFunctions.OutElastic; break; case Tween.InOutElastic: _tweenFunction = TweenFunctions.InOutElastic; break; case Tween.OutInElastic: _tweenFunction = TweenFunctions.OutInElastic; break; case Tween.InBack: _tweenFunction = TweenFunctions.InBack; break; case Tween.OutBack: _tweenFunction = TweenFunctions.OutBack; break; case Tween.InOutBack: _tweenFunction = TweenFunctions.InOutBack; break; case Tween.OutInBack: _tweenFunction = TweenFunctions.OutInBack; break; case Tween.InBounce: _tweenFunction = TweenFunctions.InBounce; break; case Tween.OutBounce: _tweenFunction = TweenFunctions.OutBounce; break; case Tween.InOutBounce: _tweenFunction = TweenFunctions.InOutBounce; break; case Tween.OutInBounce: _tweenFunction = TweenFunctions.OutInBounce; break; default: throw new ArgumentNullException("Type de Tween non géré dans le constructeur"); } }
public static Tween Animate(TweenFunction f, int duration, Expression <Func <Angle> > property, Angle finalValue, Action?completeAction = null) { var s = _setter(property, (double t, Angle initialValue) => initialValue + t * Angle.Acute(initialValue, finalValue)); return(Start(f, duration, s, completeAction)); }
public static Tween Start(TweenFunction tweeningFunction, int duration, Action <double> stepAction, Action?completeAction = null) { var tween = Instance.Create(new Tween(tweeningFunction, duration, stepAction, completeAction)); return(tween); }
public void MoveTo(float fromValue, float toValue, float time, TweenFunction func) { MoveTo(fromValue, toValue, time, func, iTween.EaseType.linear); }
public static Tween Animate(TweenFunction f, int duration, Expression <Func <Vector> > property, Vector finalValue, Action?completeAction = null) { var s = _setter(property, (double t, Vector initialValue) => initialValue * (1 - t) + finalValue * t); return(Start(f, duration, s, completeAction)); }
public Tween(TweenFunction tweeningFunction, int duration, Action <double> stepAction) : this(tweeningFunction, duration, stepAction, null) { }
public static TweenOperation Dynamic(TweenFunction function, float duration) { return(TweenDynamic.Create(function, duration)); }
/// <summary> /// Performs the tween from the start point to the endpoint, followed by the same tween from the endpoint to the start point. /// </summary> public static TweenFunction ForwardThenBackwards(this TweenFunction f) => f.CombineWith(f.Backwards());
public static TweenOperation Dynamic <T>(TweenFunction <T> function, T parameter, float duration) { return(TweenDynamic <T> .Create(function, parameter, duration)); }
public UITweener(Vector2 positionOut, TweenState state, float tween, TweenFunction function, float speed) : this(positionOut, state, tween, function, speed, function, speed) { }
public Tween(double start, double end, double time, TweenFunction tweenF) { Construct(start, end, time, tweenF); }
public DynamicZoom(float speed, TweenFunction tweenFunction) { this.tweenFunction = tweenFunction; this.speed = speed; }
/// <summary> /// Performs the tween from the start point to the endpoint, followed by the tween in reverse. /// This does not change the total time span of the function; therefore, animation will appear faster. /// </summary> public static TweenFunction ForwardThenReverse(this TweenFunction f) => f.CombineWith(f.Reverse());
public void MoveTo(float fromValue, float toValue, float time, TweenFunction func) { MoveTo(fromValue, toValue, time, func, iTween.EaseType.linear); }