Demigiant / dotween

A Unity C# animation engine. HOTween v2
http://dotween.demigiant.com
Other
2.34k stars 351 forks source link

[DOTween Pro] Tweens play in editor but not when game is playing? #590

Closed farazk86 closed 2 years ago

farazk86 commented 2 years ago

Hi,

This is related to DOTween Pro. I'm simply trying to scale a UI button using the Pro components. Below is the settings for this

Screenshot 2022-07-31 at 12 20 18

I even tried with AutoPlay enabled but it still wont work. My timeScale is also not set to 0. So its not a time scale issue. And even if I enable "ignore Time Scale", it still does not work in Play mode

When I click Play in the Preview mode, it tweens and works. But when the game is playing the tween wont work.

Can you please advise how to fix this?

Im using Unity 2020.3.15f2

Thanks

Demigiant commented 2 years ago

Ahoy,

The setup seems good to me, I can think of 3 reasons why the animation might not be happening:

  1. your Unity TimeScale is set to 0
  2. yout target button scale at runtime is set to 1.1 before the tween starts
  3. you're calling DOTween.KillAll (or another tween kill method) after the tween starts

I would check the first one first, which seems more probable

farazk86 commented 2 years ago

Thank you for the quick response.

None of the three reasons apply to my case,

Whats strange is that I tried to do that normally using script and attached the following script to the button:

void Start()
    {
        gameObject.GetComponent<RectTransform>().DOScale(1.2f, 1f).SetLoops(-1, LoopType.Yoyo);
    }

And it still wont tween... what can be the reason?

The strange thing is that other tweens in this scene are working. Such as when I click a UI button and I want the sub menu to change the DOAnchorPos works.

But the scale is not working??

farazk86 commented 2 years ago

Thank you for the quick response.

None of the three reasons apply to my case,

* The timeScale is set to 1, and even if I enable ignore time scale it still does not play..

* Ive checked and the scale at start is 1, even if I set a very large value for testing such as TO 10, it still does not play.

* Im only using DOTween.KillAll when the Quit button is clicked, other than that its not used anywhere.

Whats strange is that I tried to do that normally using script and attached the following script to the button:

void Start()
    {
        gameObject.GetComponent<RectTransform>().DOScale(1.2f, 1f).SetLoops(-1, LoopType.Yoyo);
    }

And it still wont tween... what can be the reason?

The strange thing is that other tweens in this scene are working. Such as when I click a UI button and I want the sub menu to change the DOAnchorPos works.

But the scale is not working??

@Demigiant, Right, so I managed to fix this. Now the code I wrote is working, but DoTweenPro is still not working

What fixed the code was that on the image component of the button Raycast Target was disabled. When I enabled that the button finally started tweening. 🥳

I dont remember reading this in the documentation that raycast target is required for the twen to work.. maybe I missed that.

But the Pro component is still not working, even if I enable the raycast target and remove my script and add the Pro component as shown in my post above.. it does not scale... this kind of defeats the purpose of the pro version 😞

Demigiant commented 2 years ago

I am really sure that it's some external factor that is preventing the Pro tween to work. Raycast target has no effect on if a tween (code-based or pro-based) plays or not, so something else is definitely happening, maybe related to that. If you want, send me a zip that replicates the issue, but really: external factor is the key

Demigiant commented 2 years ago

To clarify: there is some external factor/code that is either forcing your target to a fixed scale, or killing the tween. I would say the first one

farazk86 commented 2 years ago

I am really sure that it's some external factor that is preventing the Pro tween to work. Raycast target has no effect on if a tween (code-based or pro-based) plays or not, so something else is definitely happening, maybe related to that. If you want, send me a zip that replicates the issue, but really: external factor is the key

That is most probably the case. And yes, I find it very strange as well that the code tween started working when I enabled Raycast Target..

But its working at least so I'll just leave it at that for now.

Thanks a lot for trying to help 😄