Author Topic: Pause a animation with UI2DSpriteAnimation and UIbutton  (Read 2058 times)

jarenas

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Pause a animation with UI2DSpriteAnimation and UIbutton
« on: July 07, 2014, 06:31:55 AM »
Hi,

I'm trying to do a pause in the middle of an animation. When User press a GameObject I play the animation. When user release the GameObject the animation has to stop/pause.

In PC all works fine. The animation has 12 sprites. For example, if the animation is running and I pause it at sprite number 5, after I assign this sprite to UIButton.normalSprite. Then it works well and I see this gameobject in that state.

But the problem is when I export this app to tablets. In a Samgsung 10", I press the GameObject and the animation starts. All seems to work. When I leave/release the GameObject the sprite of UIButton.normalSprite and UISprite is the same and the first sprite of the animation. It is like the animation creates a reset. But If I press again the GameObject the animation go on from the same point I left, the sprite number 5. I mean, my code seems to run fine, because in PC it works perfectly. But in tablets the behaviour change.

I've put some labels to receive information and I see the sprites of UISprite and UIButton never change. Or somethins change it to the first animation sprite.

I need to resolve it soon...

Regards,
Jordi

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Pause a animation with UI2DSpriteAnimation and UIbutton
« Reply #1 on: July 08, 2014, 08:30:21 AM »
UIButton caches the normal sprite's name in its OnInit() function, but if you switch the sprite via the normalSprite property then it should be updated just fine. What do you use for your animation? If you switch the sprites yourself instead of via the normalSprite, then it won't be remembered.