- Home /
Application.LoadLevel() causes crash on Windows if mouse click
Hello! I'm using application.loadlevel() in a scene to load the next one, but in the exe file (on Windows) if I click with the mouse during loading time, it crashes the game
do you know what could be the problem?
thanks in advance, Fabio
Hello everyone! still no use, I tried with Scene$$anonymous$$anager.LoadScene ("NameOfTheScene"); but it has the same problem, if the player click with the mouse, the game crashes. (if not the scene is loaded correctly).
do you know what could be the problem?
thanks
Answer by jquin · Jul 10, 2016 at 08:23 AM
Use SceneManager.LoadScene("sceneName") instead. Aplication.LoadLevel() is obsolete. http://docs.unity3d.com/ScriptReference/SceneManagement.SceneManager.LoadScene.html
Answer by AnneSchmidt_legacy · Jul 10, 2016 at 07:54 AM
First, "Application.LoadLevel()" is obsolete, use
SceneManager.LoadScene ("NameOfTheScene");
instead.
Second: why would you click during the reload process?
Answer by magicbananna · Jul 10, 2016 at 08:24 AM
I think application.loadlevel(); doesn't work anymore.
Try this instead.
using UnityEngine.SceneManagement;
As a using statement. Then use:
SceneManager.LoadScene("**** scene name or number in here****");
In your scene change function.
I am using Scene$$anonymous$$anager.LoadScene() in my game, however I have the same problem of that game crashing if the mouse is clicked while a scene is loading.
Answer by MalboM · Jul 10, 2016 at 08:38 AM
Thank you so much for the answers everyone :) I'll try it out and let you know!