- Home /
Animation not playing when returning to a previous loaded scene
Hey guys, hope you can help me
I have a scene which is loaded right after the game starts with this piece of code in an Awake function. The second line already starts the animation.
yield Application.LoadLevelAsync("MenuScene");
Menu.instance.Init();
And in this scene i load the proper "game Scene", and to return to this menu i use this code
public function ToMenuScene() { yield Application.LoadLevelAsync("LoadingScene");
var _loadLevel : AsyncOperation;
_loadLevel = Application.LoadLevelAsync("MenuScene");
LoadingScene.instance.Init(_loadLevel);
yield _loadLevel;
Menu.instance.Init();
}
Since internally i use Invokes to call the proper animations, i thought that could be it, but with multiple debugs i can see that all functions are called all the way to the end, except that on the second time i load the scene the menu doesn't perform any animation(it uses the animation component in unity, not a custom one).
If it helps, the animation is a multi-layered animation, but no layer is playing. Target platform is iOS.
Here's the code for the animation, animation names are in portuguese, just ignore. Both debugs show in the console
function Init() {
Debug.Log("init animation");
animationComponent["Armor_Gira"].layer = 1;
animationComponent["Armor_Gira"].wrapMode = WrapMode.Loop;
animationComponent["Escudos_Gira"].layer = 2;
animationComponent["Escudos_Gira"].wrapMode = WrapMode.Loop;
animationComponent["GarraIdle1"].layer = 3;
animationComponent["GarraIdle1"].wrapMode = WrapMode.Clamp;
animationComponent["GarraIdle2"].layer = 3;
animationComponent["GarraIdle2"].wrapMode = WrapMode.Clamp;
animationComponent["GarraIdle3"].layer = 3;
animationComponent["GarraIdle3"].wrapMode = WrapMode.Clamp;
animationComponent["MenuBox1_Build"].layer = 4;
animationComponent["MenuBox1_Build"].wrapMode = WrapMode.ClampForever;
animationComponent["MenuBox1_Unbuild"].layer = 4;
animationComponent["MenuBox1_Build"].wrapMode = WrapMode.ClampForever;
animationComponent["MenuBox2_Build"].layer = 5;
animationComponent["MenuBox2_Build"].wrapMode = WrapMode.ClampForever;
animationComponent["MenuBox2_Unbuild"].layer = 5;
animationComponent["MenuBox2_Build"].wrapMode = WrapMode.ClampForever;
animationComponent["Orbit"].layer = 6;
animationComponent["Orbit"].wrapMode = WrapMode.Loop;
animationComponent["Camera_Anim1"].layer = 7;
animationComponent["Camera_Anim1"].wrapMode = WrapMode.Clamp;
animationComponent["Camera_Anim2"].layer = 7;
animationComponent["Camera_Anim2"].wrapMode = WrapMode.Clamp;
animationComponent["Camera_Anim3"].layer = 7;
animationComponent["Camera_Anim3"].wrapMode = WrapMode.Clamp;
animationComponent.Play("Orbit");
IdleAnimationCoroutine();
Debug.Log("init end");
}
Any of you guys had this problem before? Any help or suggestion is deeply appreciated
Answer by Unity_gamer · Aug 09, 2012 at 04:15 PM
If you are using Time.timescale value to pause the Game just make sure that you are turning it back to 1.!!
I'm embarrassed to say after 2 years, this has been my issue all along....
I was having trouble with my Gif Animator Plugin! I did not think this would be the issue, but it turned out to be! I've been trying to debug for a while and glad I found this.
Thanks!
Answer by burnill · Apr 06, 2012 at 05:58 PM
I had a problem that when I quit from my level to the menu the start up animation in the menu wouldn't play. It turns out I paused the game and then clicked Quit to menu but never "Unpaused" the game so the animations are frozen. Perhaps that may be your problem?
Yes! Omg, It would have taken me forever to notice this. It was exactly this for me. Thank you!
Your answer
Follow this Question
Related Questions
Using the "Fade"-Class crashes unity-iphone build... 1 Answer
Unity Invoke method delay factor vary device to device 1 Answer
How to achieve best fps for Animating - Built-in Unity animation or coded through Javascript? 1 Answer
AnimationEvent not reliably triggerd on iPhone 1 Answer
The name 'Joystick' does not denote a valid type ('not found') 2 Answers