Nomenclature(命名規則)
Tweener:A tween that takes control of a value and animates it.
補間動畫:管理一個值並在這個值上創建動畫。
Sequence:A special tween that, instead of taking control of a value, takes control of other tweens and animates them as a group.
序列:序列是特殊的補間動畫,它並不管理值,而是管理其他的補間並且以一個群組的方式創建補間集合的動畫。
Tween:A generic word that indicates both a Tweener and a Sequence.
補間:一個籠統的單詞,既可以代表補間動畫也可以代表序列。
Nested tween:A tween contained inside a Sequence.
嵌套補間:包含在序列中的補間。
Prefixes(前綴)
Prefixes are important to use the most out of IntelliSense, so try to remember these:
前綴幾乎是我們在感官上識別如何准確使用的最重要的組成,所以請務必記住這些:
- DO
- Prefix for all tween shortcuts (operations that can be started directly from a known object, like a transform or a material). Also the prefix of the main DOTween class.
- DO是所有補間快捷方式(對於快捷方式的含義我們在下一部分會提到)的前綴 ,DO作為前綴的補間可以對一個已知的對象進行操作,比如transform對象或material對象。這也是主要類 DOTween 的前綴。我們看以下的示例:
-
1 ransform.DOMoveX(100, 1); 2 transform.DORestart(); 3 DOTween.Play();
- Set
- Prefix for all settings that can be chained to a tween (except for From, since it’s applied as a setting but is not really a setting).
- 對於一個補間我們可以還進行一些設置,這些設置我們用Set作為前綴(From卻沒有使用Set作前綴,因為它以設置的方式使用但不是真正的設置) 。
-
1 myTween.SetLoops(4, LoopType.Yoyo).SetSpeedBased();
- On
- Prefix for all callbacks that can be chained to a tween.
- 對於一個補間,我們還可以設置回調函數,這些回調函數用On作為前綴。
-
1 myTween.OnStart(myStartFunction).OnComplete(myCompleteFunction);
DOTween.Init(初始化)
The first time you create a tween, DOTween will initialize itself automatically, using default values.
第一次在創建補間,DOTween 會自動初始化自身,使用默認值。
If instead you prefer to initialize it yourself (recommended), call this methods once, BEFORE creating any tween (calling it afterwards will have no effect).
如果你傾向於自己手動將其初始化(推薦),請在創建愛你任何補間之前調用一次此方法(創建之后調用無效)。
Consider that you can still change all init settings whenever your want, by using DOTween’s global settings.
但通過DOTween的全局設置,您仍可以隨時更改初始化設定。
Optionally, you can chain SetCapacity
to the Init method, which allows to set the max Tweeners/Sequences initial capacity (it’s the same as calling DOTween.SetTweensCapacitylater).
1 static DOTween.Init(bool recycleAllByDefault = false, bool useSafeMode = true,LogBehaviourlogBehaviour = LogBehaviour.ErrorsOnly);
- Initializes DOTween. Call it without any parameter to use the preferences you set in DOTween’s Utility Panel (otherwise they will be overrided by any eventual parameter passed).
- 初始化 DOTween時,如果不加任何參數,DOTween.Init方法會使用DOTween's Utility Panel的Preference中設定的值(如果你加了參數,這個參數會覆蓋Preference中的設定值)。
-
-
If TRUE all new tweens will be set for recycling, meaning that when killed they won’t be destroyed but instead will be put in a pool and reused rather than creating new tweens. This option allows you to avoid GC allocations by reusing tweens, but you will have to take care of tween references, since they might result active even if they were killed (since they might have been respawned and might now be in use as other completely different tweens).
如果recycleAllByDefault設定為True,那么所有的補間在被Kill后不會被立即銷毀,而是被存放起來並且在創建新的補間時會被重用。這個選項讓你避免了重用補間時分配Garbage Collector。但你還是必須小心對待tween的引用,因為這種模式可能導致tween在kill后被激活。 - If you want to automatically set your tween references to NULL when a tween is killed you can use the OnKill callback like this
- 如果你想自動的在tween被kill后把tween的引用設置為空,你可以這樣設置回調函數:
-
1 .OnKill(()=> myTweenReference = null)
You can change this setting at any time by changing the static DOTween.defaultRecyclable property, or you can set the recycling behaviour for each tween separately, using SetRecyclable.