Demigiant / dotween

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

Strange issue with button on 2017.1.1p3 #155

Open PixelEnvision opened 7 years ago

PixelEnvision commented 7 years ago

Hi,

I've just tried upgrading one of my projects with dotween to 2017.1.1p3 (from 5.6.3p4) and noticed a regular UI button is not working as it's calling the onClick function twice when clicked.

It's a regular Unity UI button and it has punch/scale DoTweenAnimation attached to it. Button's onClick function does 3 things:

  1. DORestart on self so punch animation works on every click
  2. Audio.Play
  3. My function call

I found that the button works properly if I remove the DORestart call. Somehow it causes button to send onClick event twice.

Any thoughts?

DDTween 1.1.640 DOTweenPro 0.9.690

PixelEnvision commented 7 years ago

I've just tried the following and it seems to work that way, so the bug is definitely linked to DORestart.

  1. Replaced DORestart with DOPlay on the button's onClick event
  2. Enabled onComplete event of DoTweenAnimation and placed DORewind there for itself.
PixelEnvision commented 7 years ago

One more piece of information that might be helpful. Animation component doesn't needs to be on the same button, it can be on a different object. As long as button calls DOResart, it triggers events twice.

  1. Normal Unity UI button calls a function somewhere and also calls DORestart on a different object (#2).
  2. Another UI object with DoTweenAnimation, DoTweenAnimation even doesn't needs be active. It just needs to be there to be able to linked to the button.

As far as I've tested, this only happens with DORestart call.

Demigiant commented 7 years ago

Ahoy,

I tried to reproduce this, following the indications you gave including the extra animated object, but everything works correctly here. Can you attach a sample project that reproduces this issue?

Cheers, Daniele

PixelEnvision commented 7 years ago

Repo.zip

You should see "Func Called" debug log posted twice on the console with a single button click.

Repo project attached. :) I'll write my full sys config next, just in case.

PixelEnvision commented 7 years ago

That's on Mac, High Sierra (Just in case if that matters some how) with Unity 2017.1.1p3

Latest DOTweenPro from the AssetStore (folder removed in repo of course)

sharklab commented 6 years ago

https://issuetracker.unity3d.com/issues/ui-dot-button-dot-onclick-event-is-firing-twice