Hi,
I use SkeletonGraphic UI to animate.
mySkeletonGraphic.AnimationState.SetAnimation(0, animeRef, loop).TimeScale = timeScale;
After completion I would like to reset animation to default state (which is set in Inspector) or if there an option to set default (idle) state and on each completion to return to that state.
I know there are events as OnComplete but to subscribe to each animation state and then unsubscribe - it's frustrating I think.
But anyway OnComplete event doesn't work for me since it will run on each completion even if animation is set to loop.
I need run move_animation on button click and as soon as first animation complete loop the idle_animation.
Страница 1 из 1
eko_lx
2 months ago
- eko_lx
- Сообщения: 4
Harald
You have two ways of subscribing to AnimationStateListener callbacks:eko_lx писал(а):I know there are events as OnComplete but to subscribe to each animation state and then unsubscribe - it's frustrating I think.
- registering at the
AnimationState
for any animation viaskeletonAnimation.AnimationState.Complete += YourMethod
. - for the events of a single
TrackEntry
viavar trackEntry = animationState.SetAnimation(0, "walk", true);
trackEntry.Complete += YourMethod;
Note that it's
Complete
and not OnComplete
, which is an internal method.This sounds more as if you want to use theeko_lx писал(а):But anyway OnComplete event doesn't work for me since it will run on each completion even if animation is set to loop.
I need run move_animation on button click and as soon as first animation complete loop the idle_animation.
End
event then. Please have a look at the documentation here for which event suits your needs: AnimationStateListener
2 months ago
-
Harald - Сообщения: 2778
eko_lx
On end of one animation I need to run another one.
Using even End event I will enter into the loop of events.
So, there are only one solution is to unsubscribe from event if the current animation state is a loop.
Using even End event I will enter into the loop of events.
So, there are only one solution is to unsubscribe from event if the current animation state is a loop.
2 months ago
- eko_lx
- Сообщения: 4
Harald
I'm afraid I don't understand what you are trying to achieve. Could you please describe the whole use case: what animations are playing, what you would like to happen, why you set some animations to looping, eventually what should be able to interrupt animations, etc.
2 months ago
-
Harald - Сообщения: 2778
eko_lx
I need to run one animation (let's say "move_animation") on button click and as soon as first animation complete run the second animation ("idle_animation") and set loop to true.
Whenever I will click the button repeat the same routine.
If I will subscribe to End event or any other event this routine will run infinitely from first button click.
Whenever I will click the button repeat the same routine.
If I will subscribe to End event or any other event this routine will run infinitely from first button click.
2 months ago
- eko_lx
- Сообщения: 4
Harald
The easiest way would be to call
If you really want to use the callback delegate methods, you just have to register to End or Complete of the first animation, as I said earlier.
SetAnimation()
to immediately start "move_animation", immediately followed by calling AddAnimation()
for "idle_animation".If you really want to use the callback delegate methods, you just have to register to End or Complete of the first animation, as I said earlier.
var trackEntry = animationState.SetAnimation(0, "move_animation", false);
trackEntry.Complete += SwitchToIdleMethod;
I fail to see what would cause problems with the above code.trackEntry.Complete += SwitchToIdleMethod;
No, it will not if you register toeko_lx писал(а):If I will subscribe to End event or any other event this routine will run infinitely from first button click.
trackEntry.Complete
or trackEntry.End
. 2 months ago
-
Harald - Сообщения: 2778
eko_lx
Thank you
1 month ago
- eko_lx
- Сообщения: 4
Harald
You're welcome.
1 month ago
-
Harald - Сообщения: 2778
Mark topic unread
• Страница 1 из 1
Вернуться в Unity
- Часовой пояс: UTC