Hi all,
The Unity Editor (and the web player aswell) is crashing when i call an Application.LoadLevel function.
My project has 9 scenes arranged as following:
Main Menu—Room1—Room2
Room1—Room3—Room4
Room1—Room5—Room6
Room1—Room7—GameOver
When I play starting from Room1, i complete the game in most of the times i test.
When I play since the MainMenu scene, it crashes when i try to load Room3.
I also have a build that loads Room3, but not the Room4 (web player)
On the MainMenu scene, there is nothing but 4 buttons (Credits, Instructions, Quality Settings and Start Game)
I’ve already tried a new MainMenu scene with just a button to start the game. It worked once or twice, but eventually the game crashes.
I searched the forum and saw something about a problem with LoadLevel and some hotfix for it, but it was for iPhone.
Does anyone have any clue what is hapenning or if there is any hotfix for my problem ?
Thanks in advance and sorry for my english,
Raphael
Does it work fine on the editor itself ??
because it should… try to run on the editor first
Hi Potan,
Yes, it crashes both on Editor and Web Player.
Thanks for the reply.
How does it crash? What does happen exactly when you try to load the level? Any error messages? Have you checked the application log files?
How does the code that loads the level look like?
Hi freyr,
That’s what i get from Editor.log:
Mono: successfully reloaded assembly
Reload assembly time: 0.344825
found == m_Lights.end () (Filename: /Users/unity-build/Desktop/automatic-build-2/unity/Projects/…/Runtime/Camera/LightManager.cpp Line: 239)
terminate called after throwing an instance of ‘std::length_error’
what(): vector::reserve
Stacktrace:
Receiving unhandled NULL exception
*** Launching bug reporter due to crashbug.
-------------- End of Log --------------
The loadlevel code is just a simple Mouse Event handler calling the following when the door is clicked:
Application.LoadLevel(“refeitorio”);
I also tried with:
GUI.Label(new Rect((Screen.width/2)-(pers.fundoCarregando.width/2),(Screen.height/2)-(pers.fundoCarregando.height/2), pers.fundoCarregando.width, pers.fundoCarregando.height), pers.fundoCarregando);
GUI.Label(new Rect((Screen.width/2)-60, (Screen.height/2)-20, 100,100), (Application.GetStreamProgressForLevel(pers.strLevelPraCarregar)*100).ToString("00")+ " %", pers.carregandoStyle);
if (Application.CanStreamedLevelBeLoaded(pers.strLevelPraCarregar))
{
// print(pers.strLevelPraCarregar);
Application.LoadLevel(pers.strLevelPraCarregar);
}
Thanks in advance for any help.
Based on the Editor.log, the problem is on the lightning of the scene to be loaded.
The difference between this scene and the others is that the character is holding a flashlight. So i turned the flashlight (a Spot Light on an object on the hand of the character) off.
It worked !
For a workaround, i called a coroutine on Awake() to wait for 1 second and turn the flashlight on again.
Everything is working now, but i still wonder why Unity is crashing with this spotlight turned on. Also, when i ALT+Tab the app and it pauses, when i focus back on the app, it crashed. Again, the workaround was the use of OnApplicationPause(bool pause) to monitor this and turn on and off the flashlight.
Thanks again for the help
I hope this helps someone too.
I just starting encountering this issue myself, once I started testing with linking my scene files together with Application.LoadLevel
Has there been any confirmation that lighting can be causing this? It is definitely a web player only issue, not on loading levels, but on comanding a reload from the browser. It seems to crash Firefox 3.5 on every machine I’ve tried it on.