- Home /
Android: Scene change (Application.LoadLevel) has no effect
I made a game which is now stuck in the reviewing process of Samsung Apps.
If I'm testing it on Windows everything works fine, but on some Samsung Tablets this thing keeps happening:
The GUI.Buttons in the level selection won't work. All it should do is change the scene. The command I used is Application.LoadLevel(Level);
The game doesn't freeze or anything, it just has no effect if the button is pressed.
It's my first game on Android, so I have no idea what could be wrong or if there are some hidden error messages I didn't see. I'm hoping for a quick answer with a possible solution or workaround, as I have not much time left until the game's release will be announced. Thanks!
It's a bit hard to say without seeing the code, but are you completely sure the button itself is set up correctly?
Application.LoadLevel("Name of level");
might work.
or..
function LoadLevel(levelName: String){
Application.LoadLevel(levelName);
}
Then call this function on the button press with the name of level you want.
LoadLevel("Name of level");
I think it maybe doing nothing as you have not told unity what level to load. (I think).
Tim.
Thanks for the answers!
I don't think the mistake is in the code, because it works on every device except some samsung tablets. Here is what I do:
if (GUI.Button (Rect (myWidth/3.84 + $$anonymous$$odulo_i*GapX, myHeight/6.72 + DivideForLine*GapY, myWidth/10.8, myHeight/6.6), ""+(i+1), StyleLevelSelection)) {
Application.LoadLevel(i+1);
}
So there is a button (and later a many of them arranged in rows), which is drawn correctly and which should lead to a specfic level. The "i" in Application.LoadLevel(i+1);
is an integer which represents the number of the level. So for example on the button for Level 1 it will do this: Application.LoadLevel(0+1);
, which will load Level 1.
As said this works perfectly if tested in the editor, so I guess there is a problem with loading levels on Samsung devices, but I have no clue what it could be.
Add a Debug.Log()
before the LoadLevel
line so you can be sure that the Button has been pressed.
I managed to look at the log files of the device. The button works but there is an error message:
09-18 15:22:46.416: E/Unity(17470): Level '' (1) couldn't be loaded because it has not been added to the build settings.
The Levels (in this case Level 1) are however correctly placed in the build settings of the editor...
Answer by Akelator · Oct 01, 2014 at 08:14 PM
This is not a pro-answer but it works for me.
Export the proyect and all assets as new package.
Create new proyect.
Import the package in the new proyect.
Drag the scenes in build settings and put them in the correct position.
Build the new proyect for android.
Fixed! :)
Answer by tanoshimi · Oct 02, 2013 at 06:13 AM
Is "i" being initialised correctly? (it's not shown in your code snippet) What happens if you hardcode the call to Application.LoadLevel(1); rather than Application.LoadLevel(i+1); ?
Do you have other levels apart from your level selection screen and level 1? If so, try changing their order around in the build settings or rename them to see if there's any problem affecting only your current level 1.
Answer by liortal · Jan 05, 2015 at 01:58 AM
9-18 15:22:46.416: E/Unity(17470): Level '' (1) couldn't be loaded because it has not been added to the build settings.
This error happens when you forget to check a new scene in build settings.
Go to your build settings in the editor (File->Build Settings) Make sure that all scenes that you attempt to load at runtime are checked (have a V next to them).