"Go" dotween (hotween V2) tutorial

Source: Internet
Author: User
Tags activate safe mode rewind



Original Dotween (Hotween V2) tutorial






Official website: http://dotween.demigiant.com/



: http://dotween.demigiant.com/download.php



Quick Start: http://dotween.demigiant.com/getstarted.php



Official Document: http://dotween.demigiant.com/documentation.php





First, the preparatory work


1, download Dotween, extract to Unity's asset folder, if you use Unity version less than Unity4.3, please delete all DOTween43 files






2. When you create a new script, you need to import the command space at the top:



Using DG. tweening;


3. Initialize global options (optional)



Dotween.init (Autokillmode, Usesafemode, Logbehaviour);

If you do not (or after you create the first tween) Dotween will be automatically initialized to default values, but you can still change them


Second, Introduction




Dotween can use a completely generic approach, like this






You can also use the handy method, like this






Whichever way you choose, when you create a tween you will return a tweener or a sequence (the difference between the two), and if you need to save it, you can save the two as tween without having to care about the difference.



You can control multiple tween in different ways, you can use the static Dotween method (there are additional options for filtering) ...


Rewind All tweens undo All tweendotween.rewind (); //Rewind all tweens with a given ID revoke Tweendotween.rewind (myId) According to the specified ID;


Direct Tween Reference

Rewind a referenced tween revoke the referenced tweenmytween.rewind ();


or more ways

Rewind all tweens connected to a specific transform revokes all tween into a specific transformtransform. Dorewind ();
Third, global or specific settings


You can set the global settings to apply to all newly created motion tweens, or by setting each individual tween animation.


Global Settings


Global settings allow you to set default AutoPlay and Autokill behavior, ease type,global timescale, and similar things.


Specific settings


The specific settings are distributed through the chain, and they all start with "Set" (except callbacks, which starts with "on"), so IntelliSense helps you find them, here are some examples



// Create a transform tween and set its ease, loops and OnComplete callback (Create a transform tween, set type to ease, loop, OnComplete callback)
transform.DOMove (new Vector3 (2,2,2), 2) .SetEase (Ease.OutQuint) .SetLoops (4) .OnComplete (myFunction);

// Same as above but using line breaks to make it more readable (same as above, but using line breaks to make it more readable)
transform.DOMove (new Vector3 (2,2,2), 2)
   .SetEase (Ease.OutQuint)
   .SetLoops (4)
   .OnComplete (myFunction);

// Same as above but storing the tween and applying settings without chaining (same as above, but no way to use chaining)
Tween myTween = transform.DOMove (new Vector3 (2,2,2), 2);
myTween.SetEase (Ease.OutQuint);
myTween.SetLoops (4);
myTween.OnComplete (myFunction); In addition, a class of tween types have special additional functionality, depending on the type of value tween depending on the value tween, which can be set by setting setoptions () Just remember that setoptions () is special, and it needs to be linked immediately after the method that primarily creates the tweened animation:
 

// Same as the previous examples, but force the transform to
// snap on integer values (very useful for pixel perfect stuff)
// Similar to the above example, but you need to force transform to temporarily adjust the value (very useful for pixel perfection)
transform.DOMove (new Vector3 (2,2,2), 2)
   .SetOptions (true)
   .SetEase (Ease.OutQuint)
   .SetLoops (4)
   .OnComplete (myFunction); 


You can even copy a tween setting to another tween, using SETAs ():



// Create a tween with some settings and store it as a Tween
Tween myTween = transform.DOMove (new Vector3 (2,2,2), 2)
   .SetEase (Ease.OutQuint)
   .SetLoops (4)
   .OnComplete (myFunction);

// Create another tween and apply the same settings as the previous one (create another tween and apply the settings of the previous tween)
material.DOColor (Color.red, 2) .SetAs (myTween); 


(These two tween willLoop 4 times, Easetype to Outquint, MyFunction will be called when tween is complete)


Fourth. Tween Life (lifecycle)





It will play automatically when you create the tween (unless you set the global Defaultautoplay behavior) until the loop is completed



When tween is finished it automatically terminates (unless you set a global Defaultautokill behavior), which means that you can no longer use it.



If you want to reuse the same tween, you just need to set its autokill to False (you can set all tweens through the global Autokill or set tween (False) for your own setautokill).



If your tween target is null, it will be reported as an exception when playing tween, you need to be aware of or activate Safe mode


Fifth, Cache and tween Max


If you have a cache pool that caches all the tween that you create, they can be reused and do not need to create a new one.



You can also avoid using more resources, it will limit the maximum of 200 tweeners and 50FPS at the same time, if you need more, Dotween will automatically increase its size, of course you can set directly to avoid the situation of automatic adjustment may occur



Set Max Tweeners to + max sequences to 200 (set maximum tweeners to 300, Max FPS is $) dotween.settweenscapacity (3000, 200)At any time you want to clear the Dotween cache when tween is complete, you can call Dotween.clear (), which will kill all the tweens and release all caches.


Sixth, Recycling tween



You do not need to recycle tween manually, instead you can choose to automatically recycle all or recycle specific






However, at any time you can change Tweener's start and end values



"Go" dotween (hotween V2) tutorial



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.