mirror of
https://github.com/Cardidi/dotween-upm-fork.git
synced 2025-12-21 01:36:05 +08:00
57 lines
2.1 KiB
C#
57 lines
2.1 KiB
C#
// Author: Daniele Giardini - http://www.demigiant.com
|
|
// Created: 2014/07/10 14:15
|
|
//
|
|
// License Copyright (c) Daniele Giardini.
|
|
// This work is subject to the terms at http://dotween.demigiant.com/license.php
|
|
|
|
using System;
|
|
using DG.Tweening.Core;
|
|
using DG.Tweening.Core.Easing;
|
|
using DG.Tweening.Plugins.Core;
|
|
using DG.Tweening.Plugins.Options;
|
|
|
|
#pragma warning disable 1591
|
|
namespace DG.Tweening.Plugins
|
|
{
|
|
public class IntPlugin : ABSTweenPlugin<int, int, NoOptions>
|
|
{
|
|
public override void Reset(TweenerCore<int, int, NoOptions> t) { }
|
|
|
|
public override void SetFrom(TweenerCore<int, int, NoOptions> t, bool isRelative)
|
|
{
|
|
int prevEndVal = t.endValue;
|
|
t.endValue = t.getter();
|
|
t.startValue = isRelative ? t.endValue + prevEndVal : prevEndVal;
|
|
t.setter(t.startValue);
|
|
}
|
|
|
|
public override int ConvertToStartValue(TweenerCore<int, int, NoOptions> t, int value)
|
|
{
|
|
return value;
|
|
}
|
|
|
|
public override void SetRelativeEndValue(TweenerCore<int, int, NoOptions> t)
|
|
{
|
|
t.endValue += t.startValue;
|
|
}
|
|
|
|
public override void SetChangeValue(TweenerCore<int, int, NoOptions> t)
|
|
{
|
|
t.changeValue = t.endValue - t.startValue;
|
|
}
|
|
|
|
public override float GetSpeedBasedDuration(NoOptions options, float unitsXSecond, int changeValue)
|
|
{
|
|
float res = changeValue / unitsXSecond;
|
|
if (res < 0) res = -res;
|
|
return res;
|
|
}
|
|
|
|
public override void EvaluateAndApply(NoOptions options, Tween t, bool isRelative, DOGetter<int> getter, DOSetter<int> setter, float elapsed, int startValue, int changeValue, float duration, bool usingInversePosition)
|
|
{
|
|
if (t.loopType == LoopType.Incremental) startValue += changeValue * (t.isComplete ? t.completedLoops - 1 : t.completedLoops);
|
|
|
|
setter((int)Math.Round(startValue + changeValue * EaseManager.Evaluate(t.easeType, t.customEase, elapsed, duration, t.easeOvershootOrAmplitude, t.easePeriod)));
|
|
}
|
|
}
|
|
} |