Unity commonly used plug-in iTween

iTween is an animation library, the author created it to achieve maximum output with minimum input. Let you do development easier, use it to easily achieve various animations, shake, rotate, move, fade, color, control audio, etc.

1. Download and import iTween plug-in in Asset Store

 2. Common methods of iTween:

Object moving methods:
(1) MoveTo: Move from the original position to the target position.
(2) MoveFrom: Move from the target position to the original position.
(3) MoveAdd: Move the position of the game object over time, according to the amount provided.
(4) MoveBy: Adds the provided coordinates to the position of the game object. (Same as MoveAdd)
(5) MoveUpdate: Similar to MoveTo, it is called in the Update() or FixedUpdate() method or in a loop environment. Provides an environment for changing property values ​​each frame. Does not depend on EaseType.  

The color change of the game object:
(1) ColorTo: Gradient from the original color to the target color.
(2) ColorFrom: Gradient from a given color back to the original color
(3) ColorUpdate: Similar to ColorTo, it is called in the Update method or in an environment similar to a loop, providing an environment for changing the attribute value every frame. Does not depend on EaseType.

Game object fades in and out:
(1) FadeTo: Gradiently changes from the current transparency to the target transparency. (Calls ColorTo internally).
(2) FadeFrom: From the given transparency gradient to the original transparency. (Calls ColorFrom internally).
(3) FadeUpdate: Similar to FadeTo, it is called in the Update method or an environment similar to a loop, providing an environment for changing the attribute value every frame. Doesn't depend on EaseType (calls ColorUpdate internally).
Parameter description: alpha and amount parameters: Both are final transparency, and amount takes precedence over alpha. The internal implementation is to only change the value of color.a, and then call the corresponding Color method. 

Camera fade-in and fade-out: The free version of iTween in the Asset Store does not have
(1) CameraFadeTo: Transparency gradually changes from the current value to the specified value, and the value (0~1) 0: completely transparent, 1: completely opaque.
(2) CameraFadeFrom: Gradient from a given transparency to the original value.
(3) CameraFadeAdd: Create a fade-in and fade-out game object for simulating the camera (if it does not exist). This method needs to be called before registering the fade effect.
(4) CameraTexture: Create and return a full-screen Texture2D for fading in and out of the camera. The Texture2D is used as a parameter of CameraFadeAdd().
(5) CameraFadeDepth: Change the fade-in and fade-out depth of the camera (the z-axis value of the object created by CameraFadeAdd()) (
6) CameraFadeSwap: Reset the guiTexture.
(7) CameraFadeDestroy: Delete the fade-in and fade-out effect of the camera (destroy the object created by ameraFadeAdd)  

Audio methods:
(1) AudioTo: gradually change the volume and pitch of AudioSource to the target value.
(2) AudioFrom: Gradually change the volume and pitch of AudioSource from the given value to the original value.
(3) AudioUpdate: Similar to AudioTo, it is called in the Update method or an environment similar to a loop, providing an environment for changing attribute values ​​​​every frame. Does not depend on EaseType.

Look class methods:
(1) LookTo: Rotate the game object to face the specified Transform or Vector3 
(2) LookFrom: Make the game object rotate from the provided direction back to the direction it was originally facing.
(3) LookUpdate: Similar to LookTo, it is called in the Update method or an environment similar to a loop, providing an environment for changing attribute values ​​​​every frame. Does not depend on EaseType.
Explanation: The front of the game object refers to the z-axis direction of the game object, that is, the z-axis of the game object points to the target point.  

Rotation methods:
(1) RotateTo: Rotate the game object to the specified Euler angle. 
(2) RotateFrom: Rotate the game object from the given Euler angle back to the original angle.
(3) RotateAdd: The Euler angle provided by the rotation angle of the game object increases with time (Vector3 three value analysis: X, Y, Z each represent which axis to rotate around. The rotation angle is X, Y, Z, The size of the value. amount: Euler angle size)
(4) RotateBy: multiply the provided value by 360, and the rest are the same as RotateAdd. That is, the value provided is the number of revolutions in each axis.
(5) RotateUpdate: Similar to RotateTo, it is called in the Update method or an environment similar to a loop, providing an environment for changing attribute values ​​​​every frame. Does not depend on EaseType. 
Note: The method of the Look class is based on the rotation of the target point, and the method of the Rotate class is based on the rotation of the angle.

Object size scaling:
(1) ScaleTo: Change the scale of the game object to the value we provide.
(2) ScaleFrom: Change the size of the object from the value we provide to the original size.
(3) ScaleAdd: Increase the size of the game object.
(4) ScaleBy: Change the size of the object exponentially. The Amount parameter is a multiple on each axis.
(5) ScaleUpdate: Similar to ScaleTo, it is called in the Update method or an environment similar to a loop, providing an environment for changing attribute values ​​​​every frame. Does not depend on EaseType. 

Example of use: Take the MoveTo() method as an example:
var args = new Hashtable();
//The name used to identify the iTween instance, you can stop the iTween with the specified name through Stop("name").
args. Add("name","myMoveTo");

//The position the game object moves to, which can be Vector3 or Transform type. Priority to xyz entry
args.Add("position", Vector3.up);

//The moving path of the game object, which can be of Vector3[] or Transform[] type. The path can be edited and obtained through iTweenPath.
args.Add(“path”, iTweenPath.GetPath(“pathName”));

//Whether to move to the starting point of the path (false: the game object is immediately at the starting point of the path, true: the game object will move from the original position to the starting point of the path.) args.Add("
movetopath", false);/ /generally use false

//The value of the x-axis of the target position, the same below
args.Add(“x”, 10);
args.Add(“y”, 10);
args.Add(“z”, 10); 

//Whether to let the game object always face the direction of the path, and the model will be automatically rotated at the corner. (If you find that your game objects are always in one direction when pathfinding then be sure to turn this on.)
args.Add("orienttopath", true);

//The target point that the game object always looks at when moving, which can be of Vector3 or Transform type. (This parameter has no effect when "orienttopath" is true)
args.Add("looktarget", Vector3.zero);

// The number of seconds the game object looks at the "looktarget".
args. Add("looktime", 0.8);

//When the "path" parameter is included and "orienttopath" is true, this value is used to calculate the value of "looktarget", indicating the position of the point where the game object looks at the front (percentage, the default is 0.05) args.Add("
lookahead ", 0.01);

// Limit rotation to only the specified axis
args.Add("axis", "y");

//Whether to use the local coordinate system (relative to the coordinates of the parent object), the default is false.
args.Add("islocal", true); 
 
//Duration of animation execution
args.Add("time", 3);

// Can be used to replace the "time" parameter to allow animations to run based on speed. (provide both "time" and "speed" parameters, the "speed" parameter will be used)
args.Add("speed", 5);

//Delay
args.Add("delay", 2);

//Easing type, enum or string name.
args.Add("easetype", iTween.EaseType.linear);

//loop type
args.Add("looptype", iTween.LoopType.none);

// The name of the method to call when the animation starts.
args. Add("onstart", "funName");

//Game object that holds the "onstart" method.
args. Add("onstarttarget", gameObject);

// Parameters sent to the "onstart" method. System.Object type
args.Add("onstartparams", "animation start");

//Called every frame during animation execution.
args.Add("onupdate", "funName");
args.Add("onupdatetarget", gameObject);
args.Add("onupdateparams",Time.time);

//Called every frame during animation execution.
args.Add("oncomplete", "funName");
args.Add("oncompletetarget", gameObject);
args.Add("oncompleteparams","funName");

// This parameter will be assigned to useRealTime static private variable. Whether to use real game time (time not affected by Time.timeScale)
args.Add("ignoretimescale",false);

//Register the animation to the target game object
iTween.MoveTo(gameObject, args);

//Whether to move to the starting position of the path (false: the game object is immediately at the starting point of the path, true: the game object will move from the original position to the starting point of the path.)

For more details, refer to the official website: http://www.pixelplacement.com/itween/documentation.php

Conclusion: The tree that embraces is born at the end of the hair; the nine-story platform starts from the pile of soil; the journey of a thousand miles begins with a single step.

Guess you like

Origin blog.csdn.net/falsedewuxin/article/details/129941615