Author Topic: UISpriteAnimation bug.  (Read 3391 times)

papirosnik

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
UISpriteAnimation bug.
« on: May 05, 2014, 07:15:57 AM »
Hello.
I'm using UISpriteAnimation on my GameObject that represents walking animal.
It uses different atlases for different states.
Atlas name is depend on movement direction ("walk_left", "walk_down", "walk_left_down" and so on).

I change atlas name when state is changed.
All works properly while sprite count in atlases is the same.

When it is different then I get troubles:
UISpriteAnimation either doesn't show all existing sprites (when the current atlas has more sprites than the previous one has) or  tries to show non-existing frames (current atlas sprite count < previous atlas sprite count).

It seems, RebuildSpriteList isn't invoked when atlas is changed.

And there is no way to manually rebuild it (except manipulations with prefix name... or we should change source code and make this method public).

It would be nice, if UISpriteAnimation could detect the case when atlas name is changed.

Fix it, please.
Thanks.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UISpriteAnimation bug.
« Reply #1 on: May 05, 2014, 11:29:40 PM »
UISpriteAnimation is more of an example script than anything else. It just shows you how you can have basic sprite-based animations, but for anything more custom like state-based animations you should really create your own controller instead.

You can make RebuildSpriteList() public and call it when you change the sprite's atlas, but I'd strongly recommend you create your custom controller script instead.

All UISpriteAnimation does is changes the names of sprites after all.

papirosnik

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: UISpriteAnimation bug.
« Reply #2 on: May 07, 2014, 05:28:11 AM »
Now i realize that the custom controller is the best decision.
Thanks.