void Start() { iTween.RotateFrom(gameObject, iTween.Hash("y", 90.0f, "time", 2.0f, "easetype", iTween.EaseType.easeInExpo)); iTween.MoveFrom(gameObject, iTween.Hash("y", 3.5f, "time", 2.0f, "easetype", iTween.EaseType.easeInExpo)); iTween.ShakePosition(Camera.main.gameObject, iTween.Hash("y", 0.3f, "time", 0.8f, "delay", 2.0f)); iTween.ColorTo(gameObject, iTween.Hash("r", 1.0f, "g", 0.5f, "b", 0.4f, "delay", 1.5f, "time", 0.3f)); iTween.ScaleTo(gameObject, iTween.Hash("y", 1.75f, "delay", 2.8f, "time", 2.0f)); iTween.RotateBy(gameObject, iTween.Hash("x", 0.5f, "delay", 4.4f)); iTween.MoveTo(gameObject, iTween.Hash("y", 1.5f, "delay", 5.8f)); iTween.MoveTo(gameObject, iTween.Hash("y", 0.5f, "delay", 7.0f, "easetype", iTween.EaseType.easeInExpo)); iTween.ScaleTo(gameObject, iTween.Hash("y", 1.0f, "delay", 7.0f)); iTween.ShakePosition(Camera.main.gameObject, iTween.Hash("y", 0.3f, "time", 0.8f, "delay", 8.0f)); iTween.ColorTo(gameObject, iTween.Hash("r", 0.165f, "g", 0.498f, "b", 0.729f, "delay", 8.5f, "time", 0.5f)); iTween.CameraFadeAdd(); iTween.CameraFadeTo(iTween.Hash("amount", 1.0f, "time", 2.0f, "delay", 10.0f)); }
iTween.RotateFrom(gameObject, iTween.Hash("y", 90.0f, "time", 2.0f, "easetype", iTween.EaseType.easeInExpo));
The RotateFrom method is used to rotate an object. Unlike RotateTo and RotateBy , RotateFrom is used to initialize the rotation of the specified angle and rotate to its original state. The method, like most of the others, is overloaded. You can use the short or detailed option: RotateFrom(GameObject target, Vector3 rotation, float time); RotateFrom(GameObject target, Hashtable args);
Hashtable args = new Hashtable(); args.Add(“y”, 90.0f); args.Add(“time”, 2.0f); args.Add(“easetype”, iTween.EaseType.easeInExpo);
Quaternion.Euler( new Vector3(0f, 90.0f, 0f) )
time=2.0f
iTween.MoveFrom(gameObject, iTween.Hash("y", 3.5f, "time", 2.0f, "easetype", iTween.EaseType.easeInExpo));
MoveFrom is similar to the previous one, everything should be clear, just moving is used instead of rotation. iTween.ShakePosition(Camera.main.gameObject, iTween.Hash("y", 0.3f, "time", 0.8f, "delay", 2.0f));
ShakePosition in this case is used to implement the “shaking” of the camera. This method makes the object move along a decreasing amplitude, does not use interpolation, the object will appear at random points, within the limits assigned to it. There is a new argument called “ delay ”, this is quite an important animation option, used to specify the time in seconds that must elapse before the animation begins. iTween.ColorTo(gameObject, iTween.Hash("r", 1.0f, "g", 0.5f, "b", 0.4f, "delay", 1.5f, "time", 0.3f));
ColorTo smoothly changes the color of the object over time. iTween.ScaleTo(gameObject, iTween.Hash("y", 1.75f, "delay", 2.8f, "time", 2.0f));
ScaleTo , as can be seen from the name of the method, changes the size of the object. iTween.RotateBy(gameObject, iTween.Hash("x", 0.5f, "delay", 4.4f));
RotateBy is reminiscent of RotateFrom , necessary in cases where you need to expand an object more than 360 degrees (although, in this case, it would be possible to do with the RotateTo method). Suppose we specified z = 2.0f , this would mean that the object should turn twice around the Z axis in a certain time interval. iTween.MoveTo(gameObject, iTween.Hash("y", 1.5f, "delay", 5.8f)); iTween.MoveTo(gameObject, iTween.Hash("y", 0.5f, "delay", 7.0f, "easetype", iTween.EaseType.easeInExpo));
MoveTo is probably the main method of the entire class iTween . It moves the object to the specified coordinates in the allotted time. Interpolation is based on the same easetype that you already know. iTween.CameraFadeAdd(); iTween.CameraFadeTo(iTween.Hash("amount", 1.0f, "time", 2.0f, "delay", 10.0f));
CameraFadeAdd creates a new object that is used to simulate dimming. The depth changes from the current value to the one specified in the arguments. The following overloads exist: CameraFadeAdd() CameraFadeAdd(Texture2D texture) CameraFadeAdd(Texture2D texture, int depth)
If Texture2D is not specified, black will be used. public class iTweenController : MonoBehaviour { int clbkN = 0; GUIStyle style; void Awake() { style = new GUIStyle(); style.fontSize = 60; } void Start() { iTween.MoveTo(gameObject, iTween.Hash("position", new Vector3(5.0f, 1.0f, 0.0f), "oncomplete", "myClbk", "loopType", iTween.LoopType.loop, "speed", 2.0f)); } void myClbk() { clbkN++; } void OnGUI() { GUI.Label(new Rect(10, 10, 0, 0), "Callback # "+clbkN, style); } }
position = new Vector3(5.0f, 1.0f, 0.0f)
This is a short entry relevant to “x”, 5.0f, “y”, 1.0f, “z”, 0.0f oncomplete = "myClbk"
Upon completion of the animation (or iteration of the animation loop), the method with the specified name is called. loopType = iTween.LoopType.loop
Kind of animation In this case, the usual loop is specified, the animation will play indefinitely, at the beginning of each animation the object will be moved to its initial position.Source: https://habr.com/ru/post/220837/
All Articles