|
I have created a simple menu using a GUISkin. I added in the code to load a new scene when a menu button is pressed, but when I try it, nothing happens. Is there anything I missed in the process of creating a working menu? Example code:
(comments are locked)
|
|
When you test your menu from Unity and try to press the button you will probably notice an error message: Level Credits couldn't be loaded because it is not added to the build settings. The code is fine and the solution straightforward. You just have to go into the Build Settings... option in the File menu. You will notice that the Credits scene you are trying to load is not there. You just have to drag it from your Project Panel in the Scenes to build section of the Build Settings window. Your menu should work now. Also it is very important that your Main menu scene (or the Scene that you want your game to load when you start it) be the first one in the Build Settings. The order of the other scenes in the Build Settings is not important. There is one case when the order is important, and that is if you write code which relies on the level's index to see which level is loaded. For example, see the documentation for MonoBehaviour.OnLevelWasLoaded. Such logic is worth avoiding, but if you have any, then be warned that the scene order in the Build Settings will matter.
Nov 20 '09 at 08:04 PM
Bampf
(comments are locked)
|
|
hi i haveing difrent problem then i use application.loadlevel in my script then i run my project i load main meniu scean and then it's automaticly loading next lvl but i made GUI button to do that my script looks like this were i added application.loadlevel private void DisplayButton() { if(GUI.Button(new Rect(Screen.width/ 2 - 50,STAT_STARTING_POINT + (10 * LINE_HEIGHT),STAT_LABLE_WIDTH,LINEHEIGHT),"Create")); { GameObject gs = GameObject.Find(" _gamesettings"); GameSettings gsScript = gs.GetComponent(); gsScript.SaveCharacterData(); Application.LoadLevel(1); } }
(comments are locked)
|
|
first of all the order of scenes is important when you want to load them with their index number and don't want to use their name. also if the problem would be about the build settings list, an error message would be shown in your game telling that you should add the scene to your list. i think you have another problem if you don't see any error(you did not say anything about it). try to print something above your Application.LoadLevel () function to see if the click even is triggered or not. Thank you for this great comments. You are right about the ordering of the scenes being important in certain cases. I never loaded a scene by it's index, so I didn't know about that. And, I was receiving the error: Level Credits couldn't be loaded because it is not added to the build settings, which is easily solved by adding the scene in the Build Settings. I think it's a common mistake among beginners.
Nov 21 '09 at 06:57 AM
ericksson
(comments are locked)
|
