DOTween

4/3/2024 Unity3d

http://dotween.demigiant.com/documentation.php (opens new window)

When using dotween, please refer to the link above

c# wrap

lua

local tf = GameObject.Find('box').transform
tf:DOMove(Vector3(0, 0, 10), 5)
tf:DOScale(Vector3(2, 2, 2), 1) --
tf:DORotate(Vector3(2, 2, 2), 1) --

tf:DOShakePosition(0.2)
tf:DOShakeRotation(0.2)
tf:DOShakeScale(0.2)
1
2
3
4
5
6
7
8

Each tween can set function callback, play, pause, kill and other functions, please refer to DoTween official documentation

每一个tween 都可以设置函数回调,播放、暂停、kill等功能,请参考DoTween 官方文档

local tween
function Start()
-- example 1, Poor readability,可读性差
--tween= transform:DOMove(Vector3(0, 0, 10), 5):OnComplete(onComplete):OnUpdate(onUpdate):OnStart(onStart):OnKill(onKill)
-- example 2,
 tween= transform:DOMove(Vector3(0, 0, 10), 5)
 tween:OnComplete(onComplete)
 tween:OnUpdate(onUpdate)
 tween:OnStart(onStart)
 tween:OnKill(onKill)
end

function onKill()
    print('kill')
end

function onStart()
    print('start')
end

function onUpdate()
    print('update')
end

function onComplete()
    print('conplete')
end
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

Last Updated: Thu, 11 Apr 2024 06:54:22 GMT