DoTween官方文档中文版(五)基本元素的快捷方式
Basic elements shortcuts(基本元素的快捷方式)
AudioMixer (Unity 5)混音器
DOSetFloat(string floatName, float to, float duration)Tweens an AudioMixer's exposed float to the given value.
Note that you need to manually expose a float in an AudioMixerGroup in order to be able to tween it from an AudioMixer.
请注意您需要手动设置一个公开的float在 AudioMixerGroup 中才能补间它从AudioMixer。
AudioSource音源
DOFade(float to, float duration)
Tweens an AudioSource's volume
to the given value..//音量飙到给定的值
DOPitch(float to, float duration)
Tweens an AudioSource's pitch
to the given value..//音调飙到给定的值
Camera(相机)
DOColor(Color to, float duration)
Tweens a Camera's backgroundColor
.//改变摄像机的背景色
DOShakePosition(float duration, float/Vector3 strength, int vibrato, float randomness)
No FROM version.
Shakes a Camera's localPosition
along its relative X Y axes with the given values.
晃动摄像机的本地坐标沿着x、y轴,根据给定的值。
strength The shake strength. Using a Vector3 instead of a float lets you choose the strength for each axis.
强度震动强度。使用 Vector3 而不一个浮点数,允许您选择每个轴的强度。
vibrato How much will the shake vibrate.
摇晃的强度。
randomness How much the shake will be random (0 to 180 - values higher than 90 kind of suck, so beware). Setting it to 0 will shake along a single direction.
Shakes a Camera's
localRotation
. //摇晃摄像机的localrotation,以下基本同上strength The shake strength. Using a Vector3 instead of a float lets you choose the strength for each axis.
vibrato How much will the shake vibrate.
randomness How much the shake will be random (0 to 180 - values higher than 90 kind of suck, so beware). Setting it to 0 will shake along a single direction.
Light(灯光)
DOColor(Color to, float duration)
Changes the light's color to the given one,
//改变灯光的颜色,color to(目标颜色),duration(渐变的时间)
DOIntensity(float to, float duration)
Changes the light's intensity to the given one
//灯光强度
DOShadowStrength(float to, float duration)
Changes the light's shadowStrength to the given one
Blendable tweens(混合补间)
DOBlendableColor(Color to, float duration)
Tweens the target's color to the given value, in a way that allows other DOBlendableColor tweens to work together on the same target, instead than fight each other as multiple DOColor would do.
补间的目标颜色为给定的值,以允许其他 DOBlendableColor 补间,共同致力于相同的目标,而不是互相争斗作为多个 DOColor 的方式会做。
LineRenderer(渲染线)
DOColor(Color2 startValue, Color2 endValue, float duration)
Changes the target's color to the given one. Note that this method requires to also insert the start colors for the tween, since LineRenderers have no way to get them.
目标的颜色更改为给定的一个。请注意此方法要求,也插入在补间的起始颜色,因为 LineRenderers 有没有办法让他们。
Color2 is a special DOTween struct which allows to store two colors in a single variable.
Color2 是一个特殊的 DOTween 结构,它允许在单个变量中存储两种颜色。
示例code:
myLineRenderer.DOColor(new Color2(Color.white, Color.white), new Color2(Color.green, Color.black), 1);
Material(材质球)
DOColor(Color to, float duration)
Changes the target's color to the given one.
DOColor(Color to, string property, float duration)
Changes the target's named color property to the given one.
更改目标的命名颜色属性设置为给定的一个。
property :The name of the property to tween.//补间的属性名称
示例code:
// Tween the specular value of a material
myMaterial.DOColor(Color.green, "_SpecColor", 1);
DOFade(float to, float duration)
Fades the target's alpha to the given value (works only with materials that support alpha).
使目标的阿尔法值按照给定的值变化,只对支持阿尔法通道的材质有效。
DOFade(float to, string property, float duration)
Fades the target's named alpha property to the given one.
property :The name of the property to tween.
DOFloat(float to, string property, float duration)
Changes the target's named float property to the given one.
property The name of the property to tween.
DOVector(Vector4 to, string property, float duration)
Changes the target's named Vector property to the given one.
property The name of the property to tween.
Blendable tweens(混合补间,同上)
DOBlendableColor(Color to, float duration)
Tweens a Material's color to the given value, in a way that allows other DOBlendableColor tweens to work together on the same target, instead than fight each other as multiple DOColor would do.
DOBlendableColor(Color to, string property, float duration)
Tweens a Material's named color property to the given value, in a way that allows other DOBlendableColor tweens to work together on the same target, instead than fight each other as multiple DOColor would do.
property The name of the property to tween.
示例code:
// Tween the specular value of a material
myMaterial.DOBlendableColor(Color.green, "_SpecColor", 1);
Rigidbody(刚体)
These shortcuts use rigidbody's MovePosition/MoveRotation methods in the background, to correctly animate things related to physics objects.
这些快捷方式在背景下,使用刚体的 MovePosition/MoveRotation 方法要正确地进行动画处理的物理对象有关的事情。
DOMove(Vector3 to, float duration, bool snapping)
Moves the target's position to the given value. //将目标移动到给定的值。
snapping: If TRUE the tween will smoothly snap all values to integers.
如果为 TRUE 则在补间将平滑的对齐所有值为整数。
DOMoveX/DOMoveY/DOMoveZ(float to, float duration, bool snapping)
Moves the target's position to the given value, tweening only the chosen axis.
移动目标到给定的值,补间只针对指定的轴。
snapping :If TRUE the tween will smoothly snap all values to integers.
Rotate(旋转)
DORotate(Vector3 to, float duration, RotateMode mode)
Rotates the target to the given value. 旋转到给定的值。
Requires a Vector3
end value, not a Quaternion
(if you really want to pass a Quaternion, just convert it using myQuaternion.eulerAngles
).
(如果你真的想要通过一个四元数,只是转换它使用myQuaternion.eulerAngles) 都需要 Vector3 的结束值,不是一个四元数。
mode:
Fast
(default): the rotation will take the shortest route and will not rotate more than 360°.
旋转将采取最短的路线,并且不会旋转超过 360 °。
FastBeyond360
: The rotation will go beyond 360°. //旋转将超越 360 °
WorldAxisAdd
: Adds the given rotation to the transform using world axis and an advanced precision mode (like when using transform.Rotate(Space.World)). In this mode the end value is always considered relative.
Adds the given rotation to the transform using world axis and an advanced precision mode (like when using transform.Rotate(Space.World)). In this mode the end value is always considered relative.
将给定的旋转添加到变换使用世界轴和先进的精密模式 (如当使用变换。Rotate(Space.World))。在此模式下的结束值始终是相对的。
LocalAxisAdd
: Adds the given rotation to the transform's local axis (like when rotating an object with the "local" switch enabled in Unity's editor or using transform.Rotate(Space.Self)). In this mode the end value is is always considered relative.
将给定的旋转添加到变换的局部轴 (如当 「 local」 的开关启用了统一的编辑器中或使用变换旋转对象。Rotate(Space.Self))。在此模式下,最终值是始终是相对。
Rotates the target so that it will look towards the given position.
朝着给定的位置旋转目标。
axisConstraint: Eventual axis constraint for the rotation.
Default: AxisConstraint.None
up: The vector that defines in which direction up is.
Default: Vector3.up
PRO ONLY ➨ Spiral – no FROM(专业版特供)
Tweens a Rigidbody's position
in a spiral shape.
补间一个刚体使用螺旋状态。
duration :The duration of the tween.
axis :The axis around which the spiral will rotate.
mode :The type of spiral movement.
speed :Speed of the rotations.
frequency :Frequency of the rotation. Lower values lead to wider spirals.
depth :Indicates how much the tween should move along the spiral's axis.
snapping: If TRUE the tween will smoothly snap all values to integers.
示例code:
transform.DOSpiral(3, Vector3.forward, SpiralMode.ExpandThenContract, 1, 10);
Rigidbody2D(二维刚体)基本与刚体一致,少了一个z轴而已。
These shortcuts use rigidbody2D's MovePosition/MoveRotation methods in the background, to correctly animate things related to physics objects.
Move
- DOMove(Vector2 to, float duration, bool snapping)
- DOMoveX/DOMoveY(float to, float duration, bool snapping)
Rotate
SpriteRenderer(2d图片渲染器)
DOColor(Color to, float duration)
Changes the target's color to the given one.
DOFade(float to, float duration)
Fades the target's alpha to the given value.
DOBlendableColor(Color to, float duration)
Tweens the target's color to the given value, in a way that allows other DOBlendableColor tweens to work together on the same target, instead than fight each other as multiple DOColor would do.
TrailRenderer(拖尾渲染器)
DOResize(float toStartWidth, float toEndWidth, float duration)
Changes the TrailRenderer's startWidth/endWidth
to the given ones
DOTime(float to, float duration)
Changes the target's time
value to the given one
Transform(变换:位置、缩放、旋转)基本同刚体
DOMove(Vector3 to, float duration, bool snapping)
Moves the target's position to the given value.
snapping If TRUE the tween will smoothly snap all values to integers.
DOMoveX/DOMoveY/DOMoveZ(float to, float duration, bool snapping)
Moves the target's position to the given value, tweening only the chosen axis.
snapping If TRUE the tween will smoothly snap all values to integers.
DOLocalMove(Vector3 to, float duration, bool snapping)
Moves the target's localPosition
to the given value.
snapping If TRUE the tween will smoothly snap all values to integers.
DOLocalMoveX/DOLocalMoveY/DOLocalMoveZ(float to, float duration, bool snapping)
Moves the target's localPosition
to the given value, tweening only the chosen axis.
snapping If TRUE the tween will smoothly snap all values to integers.
Rotate
- DORotate(Vector3 to, float duration, RotateMode mode)
- DOLocalRotate(Vector3 to, float duration, RotateMode mode)
- DOLookAt(Vector3 towards, float duration, AxisConstraint axisConstraint = AxisConstraint.None,Vector3 up = Vector3.up)
Scale
Punch – no FROM
- DOPunchPosition(Vector3 punch, float duration, int vibrato, float elasticity, bool snapping)
- DOPunchRotation(Vector3 punch, float duration, int vibrato, float elasticity)
- DOPunchScale(Vector3 punch, float duration, int vibrato, float elasticity)
Shake – no FROM
- DOShakePosition(float duration, float/Vector3 strength, int vibrato, float randomness, boolsnapping)
- DOShakeRotation(float duration, float/Vector3 strength, int vibrato, float randomness)
- DOShakeScale(float duration, float/Vector3 strength, int vibrato, float randomness)
Path – no FROM
- DOPath(Vector3[] waypoints, float duration, PathType pathType = Linear, PathMode pathMode = Full3D, int resolution = 10, Color gizmoColor = null)
- DOLocalPath(Vector3[] waypoints, float duration, PathType pathType = Linear, PathModepathMode = Full3D, int resolution = 10, Color gizmoColor = null)
Blendable tweens
- DOBlendableMoveBy(Vector3 by, float duration, bool snapping)
- DOBlendableLocalMoveBy(Vector3 by, float duration, bool snapping)
- DOBlendableRotateBy(Vector3 by, float duration, RotateMode mode)
- DOBlendableLocalRotateBy(Vector3 by, float duration, RotateMode mode)
- DOBlendableScaleBy(Vector3 by, float duration)