DOTween是一個快速,高效,完全統一的類型安全的對象屬性動畫引擎,免費開源,大量的高級特性.
DoTween兼容Unity4.5以上的版本,支持的平臺: Win, Mac, Unity WebPlayer, WebGL, iOS, Android,Windows Phone 8, Windows Store, PS Vita (PSM), PS4,Xbox One平臺,
特性:
- 速度和效率: 不僅非常快,而且非常有效:一切都是緩存和重用,避免無用的GC分配。
- 快捷: 使用擴展方法擴展公共對象用戶方便編寫代碼如下[AppleScript] 純文本查看 複製代碼123456
/
/
Move a transform
to
position
1
,
2
,
3
in
1
second
transform.DOMove
(
new
Vector
3
(
1
,
2
,
3
)
,
1
)
;
/
/
Scale
the
Y
of
a transform
to
3
in
1
second
transform.DOScaleY
(
3
,
1
)
;
/
/
Pause a transform
's
tween
transform.DOPause
(
)
;
- 幾乎支持任何動畫: 支持屬性數字,非數字, 字符串和富文本動畫展現
- 還有很多我就不一一介紹了
簡單移動Cube到達目的地:
[AppleScript] 純文本查看 複製代碼
01 02 03 04 05 06 07 08 09 10 11 12 13 14 | public Transform cube; / / Use this for initialization void Start ( ) { / / 向 0 , 4 , 0 的位置移動過去 cube.DOMove ( new Vector 3 ( 0 , 4 , 0 ) , 2 ) ; / / 從 0 , 4 , 0 的位置移動過來 cube.DOMove ( new Vector 3 ( 0 , 4 , 0 ) , 2 ) .From ( ) ; / / 向 0 , 4 , 0 的位置來回移動 cube.DOMove ( new Vector 3 ( 0 , 4 , 0 ) , 2 ) .SetRelative ( ) .SetLoops ( -1 , LoopType.Yoyo ) ; / / 另一種寫法 DOTween.To ( ( ) = > cube. position , x = > cube. position = x , new Vector 3 ( 0 , 4 , 0 ) , 1 ) .SetRelative ( ) .SetLoops ( -1 , LoopType.Yoyo ) ; } |
移動,旋轉,縮放:
[AppleScript] 純文本查看 複製代碼
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 | / / 向上移動 4 個單位 cube.transform.DOBlendableMoveBy ( new Vector 3 ( 0 , 4 , 0 ) , 2 ) ; / / 自身座標向上移動 4 個單位 cube.transform.DOBlendableLocalMoveBy ( new Vector 3 ( 0 , 4 , 0 ) , 2 ) ; / / 旋轉 cube.transform.DOBlendableRotateBy ( new Vector 3 ( 0 , 180 , 0 ) , 2 ) .SetLoops ( -1 , LoopType.Yoyo ) ; / / 本地座標系轉換 30 度 cube.transform.DOBlendableLocalRotateBy ( new Vector 3 ( 0 , 180 , 0 ) , 2 ) .SetLoops ( -1 , LoopType.Yoyo ) ; / / 開始值 ( 1 , 1 , 1 ) 5 秒內增加到 ( 3 , 3 , 3 ) cube.transform.DOBlendableScaleBy ( new Vector 3 ( 2 , 2 , 2 ) , 5 ) ; |
跳躍,衝壓機
控制DOTween方法: