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.