*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: Adding a Tween to a sequence by its ID
« Reply #15 on: April 25, 2015, 01:24:03 AM »
I managed and found the issue! With vDebugSequenceIssue set to TRUE, you were trying to add the same tween to multiple Sequences, which can't be done. I now updated DOTween to safely prevent that instead of throwing an error. Grab the version attached here and overwrite with it the Demigiant/DOTween folder (you'll also have to run DOTween's Setup from the Utility Panel again).

Re: Adding a Tween to a sequence by its ID
« Reply #16 on: April 25, 2015, 10:38:02 AM »
Ah, ok - that explains it.  I had been thinking that Sequence could be used as a way of grouping shared tweens that are to be used in more than one context, and assumed that there could be reuse of the same tweens in different sequences.  Apparently not.  All right, I guess I'll have to have handle separate copies of each one for its usage.

Hopefully this also explains another bug I was experiencing, where some tweens were strangely firing when they shouldn't, even though they weren't part of the sequence being called.  I'll see if that problem goes away now after fixing for this one.

Thanks for your effort in tracing the problem so quickly.

Re: Adding a Tween to a sequence by its ID
« Reply #17 on: April 25, 2015, 11:19:36 AM »
Okay, the other bug is still there.  This one can also be reproduced using that same sample project, if you set the vDebugSequenceIssue flag unchecked.

In the UI Canvas -> HUDPanelRight -> HUDMenuSprite object, you'll see a DOTween called HUDMenuSpriteFlashUp - the third one down.  This is just scaling the sprite up to 1.5, and as you can see Autoplay is off.  Clicking the "Show HUD" button will bring in the panels but not yet touch this tween, which is only supposed to happen later when you hit "Hide HUD".

Now however, if you change the tween direction from "TO" to "FROM" and do the "Show HUD" you'll see that the scale on the sprite is getting bumped up to 1.5 immediately even though the tween hasn't run yet.  Further investigation shows that the scaling is actually happening on the object even before clicking "Show HUD".  So it looks to me like DOTween is searching for any "FROM" scalars and applying them at startup when the tween is loading, instead of applying them at the time of playing the tween, which is what I would have expected it to do.  I have also reproduced this with my Rotate tweens as well, where I used "FROM".

Am I mistaking the usage of "FROM" here?  I would have thought that if I play a Scale tween of FROM 1.5, on an object with the scale currently at 1, that it would lerp the scale backwards from 1.5 down to 1.  Is that correct understanding?  Instead, because DOTween seems to be changing the scale to 1.5 at startup even before the tween runs, it's effectively tweening from the parameter 1.5 back to its already altered 1.5 and so it stays large and never goes back to 1 as intended.

Anyway, please advise if this is something I need to do differently, or if this is actually a bug of DOTween acting on the FROM changes in advance of its tween playing.

EDIT: I think I know what I've done wrong now.  I was firing off both the scale up and down tweens at the same time, with the down tween having a delay so that it was intended to fire off after the up tween finished.  Foolishly I thought that would take the "current value" as at the time the delay ended, but clearly it's taking it from the time the tween plays instead.

I'll see if I can get the same functionality working more appropriately using OnComplete event to call the next tween.
« Last Edit: April 25, 2015, 11:49:23 AM by cynicalwanderer »

Re: Adding a Tween to a sequence by its ID
« Reply #18 on: April 25, 2015, 12:30:09 PM »
Okay, I'm getting closer, I think.

Because I have multiple reusable tweens on each UI object, I couldn't assign the event to the correct function using DG.Tweening.DOTweenAnimation dropdown option, because that dropdown doesn't distinguish which of the multiple tweens to access a function for, and it just calls the first one it finds.  It would be nice if a particular tween could be chosen to fire in an OnComplete, but since it can't, for now instead I'm using my string based tween play function to kick the chain off at appropriate times using the events.

Which seems to work for the first iteration.  However it doesn't work the second time after that - perhaps the tween is getting killed off when executed this way, or something, even though AutoKill is turned off and my function uses Restart().  I'll keep investigating.  It does seem to me though that DOTween seems to be focused more on single-use "play at instantiation" type tweens that are expected to get killed off, rather than reusable tweens for persistent GUI objects.  Anyway, I'm sure a solution will arise.   :)

*

Daniele

  • Dr. Admin, I presume
  • *****
  • 378
    • View Profile
    • Demigiant
Re: Adding a Tween to a sequence by its ID
« Reply #19 on: April 25, 2015, 01:30:05 PM »
Hi,

About FROM, you're right: it is set as soon as the tween starts.

And about the dropdown, sadly that's a Unity issue, where there is no way to assign a specific Component (if multiple Components of the same type are present on the same GameObject) as an Inspector reference. That's why I added methods like DOPlayById or DOPlayNext (which plays the next tween on a Component, following a top-down order, that is not already playing, until its internal "tweens counter" reached the end).

About your Sequencing issues, even if DOTweenAnimation was not built to be used with Sequences, that should work. Are you Restarting the Sequence, and not the tween? After you investigate more, send me another repo so I will help you out.

Oh, and I can assure you that DOTween is definitely not focused on a single "play at instantiation" logic, quite the contrary (my tween workflow is most of the time focused on reusing existing tweens instead of "fire and forget").

P.S. I don't know if I mentioned this already, but I'm working on a Visual Editor Sequencing panel to add to DOTween Pro. It won't be tied to a single gameObject and will return a Sequence, so it should be perfect for your case. But before doing that, I'm refactoring some internal parts of DOTweenAnimation/Path, so they will share a common architecture/logic, thus it might take a while.

Re: Adding a Tween to a sequence by its ID
« Reply #20 on: April 25, 2015, 04:50:49 PM »
Okay, thanks for the explanation.  I hadn't spotted the DOPlayById and DOPlayNext - will give those a try, and they should be better than my current method.

I was restarting the sequence actually, and had been assuming that doing so would also restart the tweens inside it.  For the time being, I've switched to using code to trigger my tween chain rather than sequences, but I'll give those another try when the Visual Sequencing editor become available.