Demigiant Forum

Unity Assets => DOTween & DOTween Pro => Topic started by: par on December 15, 2015, 06:10:28 AM

Title: DOTween API Doc and Relationships between Tween and GameObject/Transform
Post by: par on December 15, 2015, 06:10:28 AM
New to DOTween, was lured in by all the good reviews.  This means I am retrofitting my code from my current tween engine to DOTween.

I lean towards coding rather than using the Unity GUI for doing anything, this way I can have complete control of whats going on.


There are many reasons why one would want this info.  One simple example is GameObject reuse.  If I have a list of GameObjects that go obsolete at the end of an animation (tween), I don't necessarily want that GameObject to be destroyed, I want to reuse it (or perhaps I really do want that destroyed.. all depends on the situation).  That means it would be nice to know all of the relationships between your framework and Unity's as depending on the use case, I might have a list of tweens that I set off or I might have a list of GameObjects/Transforms that I want to manage.

Thanks much!

PAR
Title: Re: DOTween API Doc and Relationships between Tween and GameObject/Transform
Post by: Daniele on December 15, 2015, 11:54:09 AM
Hi!


Most important, tweens are not related to gameObjects at all. DOTween is a separate engine that animates what you tell it, which can be a transform but also a float on a class that has nothing to do with Unity.

Cheers,
Daniele
Title: Re: DOTween API Doc and Relationships between Tween and GameObject/Transform
Post by: par on December 15, 2015, 03:49:55 PM
Thanks much for the fast reply!

1) Ok, ya I read your official docs and, while they cover the basics it would be nice to have a full API reference.  And I ask this as a purchaser of the Pro version, I would never expect it w/out paying :P
2/3) So you're saying that whatever is used in your shortcut methods, the tween's target is always that object?  So is the following accurate?
If this is the case I can appreciate it.  The safe thing to do during a production application would be to check the type on these before using them but if you have hundreds of them per frame, the check will be a performance hit.
4) Tween one = transform.DoMove(); List<Tween> onesTweens = DOTween.TweensByTarget(one.target)?
If the list is long, how do I check which tween is which in a performant way?  A shortcut would be an id or enum that I could place on the tween and just check equality but if I dont have that what would be your suggested way?

I usually always keep references to things so I can avoid the performance hit of doing searches (i.e. I never do GameObject.GetComponent<Whatever Component> as that is a performance hit).  But there are definitely times I will need to check what is what.

Thanks again!

PAR
Title: Re: DOTween API Doc and Relationships between Tween and GameObject/Transform
Post by: Daniele on December 15, 2015, 04:42:51 PM
Ahoy! :)

1) The official docs are the full API reference. They were a pain to create and a pain to maintain, since they require a lot of manual work, but it's the only way. API generators simply don't work with DOTween's architecture (which is pretty weird in order to boost performance), so a classic API reference is just not possible. I created it initially (you can see it here (http://dotween.demigiant.com/api/index.html)), but then I realized it's unreadable so stopped updating it and removed the link from the website.

2/3) Yes, definitely accurate

4) You can indeed add IDs to tweens (using SetId (http://dotween.demigiant.com/documentation.php?api=SetId)), so then you can get a list of tweens with the given ID (using TweensById (http://dotween.demigiant.com/documentation.php?api=TweensById)) and use that instead. Or you can filter the "list by targets" by checking the tween.id that you set.

Alternately, note also that every static DOTween control method (http://dotween.demigiant.com/documentation.php#controls) (like DOTween.Play/Pause/etc) accept a target or an ID if you want, so your operation will already be filtered.

Cheers!
Daniele
Title: Re: DOTween API Doc and Relationships between Tween and GameObject/Transform
Post by: par on December 15, 2015, 04:57:10 PM
Great!  Thanks much for your responses and I look forward to testing this all out!

And I looked at your API and yes, that would have been wonderful if it had worked.  Bummer you had so much trouble with it.

Cheers!

PAR