- Home /
Pause the game after animation is completed
Hello, everyone
(I'm using the new Unity UI system)
I have a little problem that i'm confused about how to actually get it working using the right code
I have a pause button attached to my scene, when i click the pause button it shows a pause menu that has an animation, now if i use Time.timeScale = 0 the animation won't complete, so how i tell my scene to be paused after that animation has completed?
Any help i greatly appreciated
Thank you for your time.
Answer by N1warhead · Sep 25, 2014 at 12:02 PM
It would be nice to see some code... However, I believe this will answer your question here. This is in Javascript AKA (Unityscript)
yield WaitForSeconds (animation["YourAnimationName"].length);
Hope that answered your question.
good idea, but actually i think it won't work, i have tried it IEnumerator function is not accessible by On Click()
Actually there is not much code, here it is:
Animator pausedDialog;
Public void menu() {
// this is to start the animation when pause_button is clicked
pausedDialog.enable = true;
pausedDialog.SetBool("isActive", false);
}
so, paused_Dialog object is assigned to pausedDialog and pause_button by default has On Click () function, using the "+" sign i did add the script and choose the menu function to play the animation when the button is clicked, everything works fine, but when i want the game to be paused using Time.timeScale = 0, i'm not able to get the animation working.
I guess you can understand the above script if you are familiar with the new Unity UI system
Thank you for your time.
Sorry for not getting back to you sooner.
I haven't used Unitys new UI System and don't plan on touching it until I see actual positive results with it, don't want to change my entire game until I know it's better and easier to use lol.
I'm assu$$anonymous$$g you're using C# then? Because with Unityscript you shouldn't need an IENumerator for a co-routine. At least, I never used one when I was using Unityscript, it would just call my co-routine.
I've truthfully never made a Paused function yet. But from what I can see is try to make your paused Dialog into an if statement..
Such as if(time
I don't think that is properly created, just made it off the top of my head, but maybe you can work around it with that?