http://dotween.demigiant.com/pro.php
1.安裝
下載:http://dotween.demigiant.com/download
解壓縮到Assets目錄下任意目錄,不要放到Editor,Plugins,Resources下
2.初始化
安裝好后tools下可以找到此菜單“ Tools/Demigiant”

image.png
點(diǎn)擊“ Setup DOTween”

3.代碼配置
引用
using DG.Tweening;
初始化配置
DOTween.Init(autoKillMode, useSafeMode, logBehaviour);
可選,如果不設(shè)置就按照默認(rèn)進(jìn)行,要在第一次DoTween調(diào)用前使用
4. 使用
A 直接使用
DOTween.To(()=>myValue, x=>myValue=x, 100, 1);
這句意思是將屬性變量名myValue配置為緩動曲線,執(zhí)行使用的是lamda表達(dá)式,100為目標(biāo)值,1為時間長度1秒

B transform調(diào)用
你可以直接使用transfrom的擴(kuò)展api

image.png
C 倒退
DOTween.RewindAll();
DOTween.Rewind(myId);
myTween.Rewind();
transform.DORewind();
D from方法
從給定的值移動到當(dāng)前位置點(diǎn),帶true是相對位置
transform.DOMoveX(2, 1).From();
transform.DOMoveX(2, 1).From(true);
E 事件
// Callback without parameters
transform.DOMoveX(4, 1).OnComplete(MyCallback);
// Callback with parameters
transform.DOMoveX(4, 1).OnComplete(()=>MyCallback(someParam, someOtherParam));
F 參數(shù)
設(shè)置循環(huán)和緩動曲線
TweenParams tParms = new TweenParams().SetLoops(-1).SetEase(Ease.OutElastic);
// Apply them to a couple of tweens
transformA.DOMoveX(15, 1).SetAs(tParms);
transformB.DOMoveY(10, 1).SetAs(tParms);
這樣做可以節(jié)省對每個分別設(shè)置相同的值
G 暫停 Pause
// Pauses all tweens
DOTween.PauseAll();
// Pauses all tweens that have "badoom" as an id
DOTween.Pause("badoom");
// Pauses all tweens that have someTransform as a target
DOTween.Pause(someTransform);
myTween.Pause();
transform.DOPause();
H 數(shù)值浮動
對數(shù)值進(jìn)行緩動
DOVirtual.Float(float from, float to, float duration, TweenCallback<float> onVirtualUpdate)
根據(jù)參數(shù)給出某一時刻的值
DOVirtual.EasedValue(float from, float to, float lifetimePercentage, Ease easeType \ AnimationCurve animCurve)
延遲函數(shù)
DOVirtual.DelayedCall(float delay, TweenCallback callback, bool ignoreTimeScale = true)
// Example 1: calling another method after 1 second
DOVirtual.DelayedCall(1, MyOtherMethodName);
// Example 2: using a lambda to throw a log after 1 second
DOVirtual.DelayedCall(1, ()=> Debug.Log("Hello world"));
其他
http://dotween.demigiant.com/documentation.php#globalSettings