- Home /
Unity 5 GUI Buttons Won't Show When Built
When building the game, the buttons (start, controls, quit) won't show up - they only will if I test it inside Unity.
I've tried re positioning in all sorts of ways (scale, location, etc.), changing the canvas to Screen Overlay - Camera... Nothing works. I have the Title (just a static image) and that shows up plus the background image.
This is for Windows and is 2D, by the way.
Here's the code:
`using UnityEngine;
using UnityEngine.UI;// we need this namespace in order to access UI elements within our script
using System.Collections;
using UnityEngine.SceneManagement;
public class mainMenu : MonoBehaviour
{
public Button startText;
public Button exitText;
public Button controlsText;
public Button exitControlsText;
void Start ()
{
startText = startText.GetComponent<Button> ();
exitText = exitText.GetComponent<Button> ();
}
public void StartLevel () //this function will be used on our Play button to load the first level
{
SceneManager.LoadScene(2); //this will load our first level, which is "1"
}
public void Controls () //this function will be used on our Play button
{
SceneManager.LoadScene (1); //this will load the Controls scene from our build settings, which is "1"
}
public void ExitGame () //This function will be used on our "Quit" button in the main menu
{
Application.Quit(); //this will quit our game. Note this will only work after building the game
}
public void ExitControls () //this is the exit controls button
{
SceneManager.LoadScene (0); //this will load the main menu
}
}
Comment