I am using a main menu script that I found online to give me a starting point. It works great and I have exactly what I need, except one thing. For the level select screen, I am trying to add a picture to the GUI Button that takes you to a level. However, I am having trouble finding out how to do that. Here is my script in C#: `using UnityEngine;
using System.Collections;
using UnityEngine;
using System.Collections;
public class MainMenuScript : MonoBehaviour
{
public GUISkin GameSkin;
private bool _isFirstMenu = true;
private bool _isLevelSelectMenu = false;
private bool _isLoadGameMenu = false;
private bool _isOptionsMenu = false;
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
}
void OnGUI()
{
GUI.skin = GameSkin;
GUI.Label(new Rect(30, 75, 300, 25), "Unnamed Racing Game Pre Alpha Build v0.0.1", "Menu Title");
FirstMenu();
LoadGameMenu();
LevelSelectMenu();
OptionsMenu();
if(_isLevelSelectMenu == true || _isLoadGameMenu == true || _isOptionsMenu == true)
{
if(GUI.Button(new Rect(10, Screen.height - 35, 150, 25), "Back"))
{
_isLevelSelectMenu = false;
_isLoadGameMenu = false;
_isOptionsMenu = false;
_isFirstMenu = true;
}
}
}
void FirstMenu()
{
if(_isFirstMenu)
{
if(GUI.Button(new Rect(10, Screen.height / 2 - 100, 150, 25), "New Game"))
{
Application.LoadLevel("Level01");
}
if (GUI.Button(new Rect(10, Screen.height / 2 - 65, 150, 25), "Load Game"))
{
_isFirstMenu = false;
_isLoadGameMenu = true;
}
if (GUI.Button(new Rect(10, Screen.height / 2 - 30, 150, 25), "Level Select"))
{
_isFirstMenu = false;
_isLevelSelectMenu = true;
}
if (GUI.Button(new Rect(10, Screen.height / 2 + 5, 150, 25), "Options"))
{
_isFirstMenu = false;
_isOptionsMenu = true;
}
if (GUI.Button(new Rect(10, Screen.height / 2 + 40, 150, 25), "Quit Game"))
{
Application.Quit();
}
}
}
void LoadGameMenu()
{
if(_isLoadGameMenu)
{
GUI.Label(new Rect(10, Screen.height / 2 - 200, 200, 50), "Load Game", "Sub Menu Title");
GUI.Box(new Rect(10, Screen.height / 2 - 100, Screen.width / 2 + 100, Screen.height - 450), "Choose Saved Game");
}
}
void LevelSelectMenu()
{
if(_isLevelSelectMenu)
{
GUI.Label(new Rect(10, Screen.height / 2 - 200, 200, 50), "Course Select", "Sub Menu Title");
// Top Buttons
if(GUI.Button(new Rect(10, Screen.height / 2 - 100, 200, 150), "Mountainous Bayside"))
{
Application.LoadLevel("Level1");
}
if(GUI.Button(new Rect(220, Screen.height / 2 - 100, 200, 150), "Level 02"))
{
}
if(GUI.Button(new Rect(430, Screen.height / 2 - 100, 200, 150), "Level 03"))
{
}
if(GUI.Button(new Rect(640, Screen.height / 2 - 100, 200, 150), "Level 04"))
{
}
//Bottom Buttons
if(GUI.Button(new Rect(10, Screen.height / 2 + 60, 200, 150), "Level 05"))
{
}
if(GUI.Button(new Rect(220, Screen.height / 2 + 60, 200, 150), "Level 06"))
{
}
if(GUI.Button(new Rect(430, Screen.height / 2 + 60, 200, 150), "Level 07"))
{
}
if(GUI.Button(new Rect(640, Screen.height / 2 + 60, 200, 150), "Level 08"))
{
}
}
}
void OptionsMenu()
{
if(_isOptionsMenu)
{
GUI.Label(new Rect(10, Screen.height / 2 - 200, 200, 50), "Options", "Sub Menu Title");
GUI.Box(new Rect(Screen.width / 2, 0, Screen.width / 2, Screen.height), "");
if (GUI.Button(new Rect(10, Screen.height / 2 - 30, 150, 25), "Audio Options"))
{
}
if (GUI.Button(new Rect(10, Screen.height / 2 + 5, 150, 25), "Graphics Options"))
{
}
}
}
}`
If you look at lines 100-104, I am trying to add an image called “Image1” to that GUI Button and only that GUI Button. Can anyone help me do this?