Help With Main Menu Background Texture and LoadLevel

I somehow missed the GUI section. I will leave it to a mod to move this please. In the meantime I will be searching there :slight_smile:

Hi, I have searched for a while, but cannot seem to find the answer to two of my questions. I have a basic main menu GUI set up, but I have two more steps before I can continue.

  1. How do I apply a background Image to the Main Menu, or can I? Do I have to use a scene, or can I simply use a picture I made in Photoshop?
  2. How do I make a menu button load a level, or (which i really want) load a new menu. For example, I have button for singleplayer. I want it when I press that button, a new menu pops up with new buttons that say like “Campaign”, “Singlemission”, etc.

screenshot of what I have : photobucket

mainmenu.js:

function OnGUI () {
	GUI.Box (Rect (10,10,110,100),"");
	
	if (GUI.Button (Rect (20,50,90,20), "Singleplayer")) {
		Application.LoadLevel (1);
	}
	
	GUI.Box (Rect (1245,10,110,100),"");
	
	if (GUI.Button (Rect (1255,50,90,20), "Multiplayer")) {
		Application.LoadLevel (2);
	}
	
	GUI.Box (Rect (10,490,110,100),"");
	
	if (GUI.Button (Rect (20,530,90,20), "Options")) {
		Application.LoadLevel (3);
	}
	
	GUI.Box (Rect (1245,490,110,100),"");
	
	if (GUI.Button (Rect (1255,530,90,20),"Exit")) {
		Application.LoadLevel (4);
	}
}

Any and all help appreciated!!! Thank you much. And BTW, Unity is sooooooooooooo much better than the UDK!!!

Welcome to the forums :slight_smile:

Images and scenes are orthogonal concerns (in other words, it’s not a question of using a scene ‘or’ a picture). As for how to create a background image, one method would be simply to place the image on a quad and position it so that it occupies the entire screen. You could also probably use GUI textures or the built-in GUI system for this (I don’t use either that much myself, so I’ll leave the details on that to others).

To load a new level, use Application.LoadLevel(). As for switching menus, you could make each menu its own scene/level, but it might be more straightforward (and responsive) simply to arrange the program logic in your OnGUI() function such that the appropriate controls are drawn depending on which menu is currently active.

Thank you. There is so much more to do than in UDK, and so much more to learn!!!