Author Topic: UISpriteAnimation, how to?  (Read 10446 times)

BehindTheStone

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 135
    • View Profile
UISpriteAnimation, how to?
« on: March 17, 2013, 12:50:04 PM »
Hey there.

I can't manage to animate my UI Sprites. There is one Sprite i want to animate (contains of 4 Frames)
How exactly can i do this with the UISpriteAnimation-Script? I am attaching it and when i play it, it cycles through my whole TextureAtlas.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UISpriteAnimation, how to?
« Reply #1 on: March 17, 2013, 04:04:06 PM »
Name your sprites similarly, such as Walk01, Walk02, Walk03, and Walk04. Specify the prefix "Walk" on the UISpriteAnimation, and there you go.

BehindTheStone

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 135
    • View Profile
Re: UISpriteAnimation, how to?
« Reply #2 on: March 17, 2013, 04:18:22 PM »
Ah, yeah, now i get it!

And how can i play a certain animation via Script?

Thanks for the Support!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UISpriteAnimation, how to?
« Reply #3 on: March 17, 2013, 05:30:32 PM »
By changing the prefix.

BehindTheStone

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 135
    • View Profile
Re: UISpriteAnimation, how to?
« Reply #4 on: March 17, 2013, 05:38:29 PM »
Nothing like "Play()" and "Stop()" ?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UISpriteAnimation, how to?
« Reply #5 on: March 18, 2013, 03:25:15 PM »
It's a very simple "how to" script. It's not meant to be a full-blown sprite animation system as that's outside the scope of a UI system.

2Nails

  • Guest
Re: UISpriteAnimation, how to?
« Reply #6 on: April 05, 2013, 06:58:47 AM »
Hello. I thought it would be wiser to up this one rather than opening a new one.

I'm currently trying to have an animation playing when I'm hovering a Button.
It's one of our own animations, a sprite sheet, but we can split it into one sprite by frame if necessary.

I first tried to do it with the UIButton Play Animation first, but did not manage to understand how to fill the "Target" field. I thought I might have to drag a .ANIM file into it, like the "Checkmark" that we can find in your Example\Animations folder.

But I have no idea how to make a .ANIM file from what i currently have, and moreover, for some reason i can't even drag the "Checkmark" .ANIM into the Target Field, so I felt like trying this way was pointless anyway.


I've then been looking for other solutions, and here comes the UISpriteAnimation part.

It seems to be the script one should use when it comes to animate.
I haven't really understood how to use it. I admit I'm not quite good when it comes to scripting.
I've been looking for a step by step tutorial, I really need something of this nature, the NGUI Documentation about it just doesn't make sense to me.


Would you be kind enough to explain me how I should proceed, with what i got, and to obtain what I want, or to redirect me to an existing tutorial on the topic ?
I would be truly grateful.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UISpriteAnimation, how to?
« Reply #7 on: April 05, 2013, 11:50:02 AM »
To create an animation, hit CTRL+6. This will open up the animation window, letting you record animations right within Unity. Be sure to select the root object you want to animate though (for example -- a button).

UIButtonPlayAnimation's "target" parameter accepts an animation that you create. Just drag & drop the object that has the animation on it into this field.