hello. i am having some trouble with unity and i don’t know what to do, or what caused it. (sorry if my english is bad, it’s not my main language.)
i am pretty new to Unity, and me and my class is making a game.
i was making a home page, with buttons such as the name of the game, a start, options and exit button.
i watched a video explaining how to make different pages. i made a page for options, and now i’m not able to enter my main menu page again. (it’s stuck on the options page, and the buttons where all out of sudden outside of the acual page)
Unity doesn’t have “page” as a concept, so you’ll have to be clear what pages mean to you otherwise you’re question isn’t clear. If you’re referring to scene files, you can open a previously saved scene from the File menu at the top left.
- I’m pretty sure the button-thing is related to canvas size.
- Select the Canvas
- Check you are using scale with screen size (you’re using the free aspect ratio which makes me suspect it’s this as “Constant Pixel Size” is the default).
- I don’t quite understand if you mean you’re having problems navigating between scenes or you don’t know how to hook up buttons to do exactly that (you could do something like this)
class MainMenuManager : MonoBehaviour
{
public GameObject mainMenuCanvas;
public GameObject optionsMenuCanvas;
public Button optionsButton;
public Button exitOptionsMenuButton;
private void Start()
{
optionsButton.onClick.AddListener(OpenOptionsMenu);
exitOptionsMenuButton.onClick.AddListener(CloseOptionsMenu);
}
private void OpenOptionsMenu()
{
mainMenuCanvas.SetActive(false);
optionsMenuCanvas.SetActive(true);
}
private void CloseOptionsMenu()
{
optionsMenuCanvas.SetActive(false);
mainMenuCanvas.SetActive(true);
}
}