Itween Stop Tween and Put Object Back to Start
There are many different versions of the Itween plug-in on the Internet, but the explanations are scattered in various places, so I will organize them here.
1. The principle of using iTween
The core of iTween is numerical interpolation. Simply put, it is to give iTween two values (start value, end value), it will automatically generate some intermediate values, for example: start value -> intermediate value -> intermediate value …. -> end value.
The values here can be understood as: numbers, coordinate points, angles, object size, object color, volume level, etc.
2. How to use iTween
iTween can be obtained from various places, but the most formal way is to directly search and download (free) from the Unity asset store. The main file of iTween has two iTween.cs and iTweenPath.unitypackage (this package is only needed to edit the path).
Third, the core method
iTween.MoveTo(): Move the model to a position. Its underlying function is completed by dynamically modifying the transform.position of each frame of the model, so it will reach the target point 100% without errors.
iTween.MoveFrom(): It is the same as above, iTween.MoveTo() is to move the model to the target position, and iTween.MoveFrom() is to move the model from the target position to the original position.
iTween.MoveAdd() is the same as the underlying implementation of iTween.MoveBy(), you can see the source code. Transform.Translate, which is the translation of the API, is used when processing the movement. This may cause some errors when processing the movement, but the effect is better.
iTween.MoveUpdate(): Similar to iTween.MoveTo(), except that it needs to be placed in a loop or Update().
4. Details
API:
Suffix name difference | ***From | The current value immediately becomes the target value and gradually eases to the initial value |
***To | Gradually from the current value to the target value | |
***Update | The same as To, but when using the Update function, it will increase the performance incredibly, or in the case of similar loops involving "live" settings to change the value. Not using EaseType | |
3 major events | onstart | The animation starts to trigger an event |
onstarttarget | The event loads the object to be sent by message | |
onstartparams | Parameters passed when sending a message | |
onupdate | Trigger event in animation | |
onupdatetarget | The event loads the object to be sent by message | |
onupdateparams | Parameters passed when sending a message | |
oncomplete | Animation end trigger event | |
oncompletetarget | The event loads the object to be sent by message | |
oncompleteparams | Parameters passed when sending a message | |
Public property | name | Used to stop iTweens based on independent name |
ignoretimescale | Setting to true will allow the animation to continue at the current time. This is useful for pausing the menu animation after the game is set by Time.timeScale=0 | |
easetype | Animation motion curve enumeration | |
looptype | Loop enumeration | |
time | Animation completion time | |
delay | The time to wait before starting the animation | |
From-To method | AudioFrom | Audio and volume |
AudioTo | ||
AudioUpdate | ||
CameraFadeFrom | Number of camera fades (transparency) | |
CameraFadeTo | ||
ColorFrom | colour | |
ColorTo | ||
ColorUpdate | ||
FadeFrom | The alpha value of the game object; if the attached component is light, guitext or guitexture, it will be the target of the animation | |
FadeTo | ||
FadeUpdate | ||
LookFrom | Rotate a game object over time to monitor the provided Transform or Vector3 | |
LookTo | ||
LookUpdate | ||
MoveFrom | Move: change the position of the game object to the provided target point over time | |
MoveTo | ||
MoveUpdate | ||
MoveAdd | Move increment Vector3 | |
MoveBy | ||
RotateFrom | Rotation: Rotate the game object in angle to the provided Euler angle over time | |
RotateTo | ||
RotateUpdate | ||
RotateAdd | Rotation increment Vector3 | |
RotateBy | Rotation increment Vector3*360 | |
ScaleFrom | Zoom: change the zoom of an object over time | |
ScaleTo | ||
ScaleUpdate | ||
ScaleAdd | Zoom increment Vector3, original zoom +Vector3 | |
ScaleBy | Zoom factor Vector3, original zoom *Vector3 | |
Video camera | CameraFadeAdd | Create a game object (if it does not exist) at the provided depth to simulate the fading of the camera |
CameraFadeDepth | Change the depth of fading of the camera | |
CameraFadeDestroy | Remove and destroy the fade of a camera | |
CameraFadeSwap | Change the faded texture of the camera | |
CameraTexture | Use CameraFade to create and return a full-screen Texture2D | |
Animation control | Hash | Create a hash table |
Init | Set the game object to avoid pauses when an initialization is added | |
Pause | Pause itween | |
Resume | Start iTween again | |
Stop | Stop iTweens | |
StopByName | Stop iTweens by name | |
Other methods | ValueTo | As the application expects to return an interpolation between the provided "from" and "to" to the callback method. "onupdate" callback is required |
Count | Returns the entire number of iTweens | |
EaseType | Easing type | |
LoopType | Looping enumerated types | |
Stab | Play audio clips based on the provided volume, audio, and any following delay. The audio source is optional because iTween will provide a | |
Used for tuning | DrawLine | When calling the OnDrawGizmos() function, he will draw a line through the provided Vector3 or Transforms array |
DrawLineGizmos | Use Gizmos.DrawLine() to draw a line through the provided Vector3s or Transforms array | |
DrawLineHandles | Use Handles.Drawline() to draw a line through the provided Vector3s or Transforms array. | |
DrawPath | When OnDrawGizmos() is called, he will draw a curved path through Vector3 or Transforms array | |
DrawPathGizmos | Use Gizmos.DrawLine() to draw a curved path through Vector3s or Transforms array | |
DrawPathHandles | Use Handles.DrawLine() to draw a curved path through the provided Vector3s or Transforms | |
shock | PunchPosition | Use a vibrating force to give the game object's position to shake him to his original position |
PunchRotation | Use a vibrating force to give the game object a rotation that makes him rock to his original rotation | |
PunchScale | Using a vibrating force to zoom the game object makes him rock to his original zoom | |
ShakePosition | Over time through a decreasing number of random vibrating game object positions | |
ShakeRotation | Rotate the game object with a decreasing number of random vibrations over time | |
ShakeScale | Scaling through a decreasing number of randomly vibrating game objects over time | |
path | PathLength | Returns the length of the curved path drawn through Vector3 or Transforms array |
PutOnPath | Path to place game objects based on the percentage provided | |
PointOnPath | Returns the Vector3 position on a path based on the percentage provided | |
Difference operation | FloatUpdate | Return a float easing between the current and the target value according to the provided speed; speed=1 means that the end point is reached in unit time |
RectUpdate | Return a rectangle used to buffer the current and target values through the provided acceleration; speed=1 means that the end point is reached in unit time | |
Vector2Update | Return a Vector2 used to buffer between the current and target values through the provided acceleration; speed=1 means that the end point is reached in unit time | |
Vector3Update | Returns a Vector3 used to buffer the current and target values through the provided acceleration; speed=1 means unit time |
Animation enumeration: ( http://www.robertpenner.com/easing/easing_demo.html )
Square
- easeInQuad
- easeOutQuad
- easeInOutQuad
Cube
- easeInCubic
- easeOutCubic
- easeInOutCubic
4th power
- easeInQuart
- easeOutQuart
- easeInOutQuart
5th power
- easeInQuint
- easeOutQuint
- easeInOutQuint
Sine
- easeInSine
- easeOutSine
- easeInOutSine
10th power of 2
- easeInExpo
- easeOutExpo
- easeInOutExpo
Square root
- easeInCirc
- easeOutCirc
- easeInOutCirc
Linear
- linear
Spring
- spring
Rallies
- easeInBounce
- easeOutBounce
- easeInOutBounce
BACK
- easeInBack
- easeOutBack
- easeInOutBack
Elastic band
- easeInElastic
- easeOutElastic
- easeInOutElastic
Animation curve:
EasyIn: fade in
EasyOut: fade out
EasyInOut: fade in and fade out
Loop type: none (one-time non-loop), loop (one-way loop, that is, return to the starting point immediately after reaching the end point, and then continue), pingpong (reciprocating loop)
Five, path configuration
1. Drag iTweenPath.cs to a game object, the game object will have the following attributes, the following figure shows that the path is composed of 5 nodes, and the path name is myPath.
2. You can fill in the node coordinates manually or adjust the node coordinates in the scene.
The code can refer to the official example, this article will not be introduced.
Reference documents:
http://www.xuanyusong.com/archives/2052
http://blog.csdn.net/chaixinke/article/details/44628123
http://www.manew.com/1683.html
Itween Stop Tween and Put Object Back to Start
Source: https://www.programmersought.com/article/55804147543/
0 Response to "Itween Stop Tween and Put Object Back to Start"
Postar um comentário