Options menu won't work
My intention is to have two different menus (Main and settings) appear on the one game scene, swapping between these being left up to an Options button and a Quit Settings button in their respective menus.
However I am running into multiple errors when attempting this with the limited code that I have
These problems are that I am recieving a MissingComponentException for not having the objects i have initialized in the code be attached to the actual objects. After assigining these objects in the inspector they will just be removed once i hit play.
I have also tried to make the quit options button be set to unactive immediately during or before the scene however this does not work either as it seems the code is not even acessed with either the Awake or Start method.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class MainMenu : MonoBehaviour
{
[SerializeField] public Button startbutton;
[SerializeField] public GameObject SettingsMenu;
public void Awake()
{
SettingsMenu = GetComponent<GameObject>();
startbutton = GetComponent<Button>();
}
public void Start()
{
if (true)
{
SettingsMenu.SetActive(false);
startbutton.Select();
Debug.Log("set to false");
}
}
public void PlayGame()
{
SceneManager.LoadScene("BeginningScene");
}
public void QuitGame()
{
Application.Quit();
Debug.Log("Quit game");
}
}
I can attempt to provide more information as necessary, any help would be appreciated
Your answer
Follow this Question
Related Questions
Carousell menu shows no pictures when new assetbundle is loaded 0 Answers
UI problems 0 Answers
Get child button of and object in herarchy order 0 Answers
Button Flickering On and Off When Pressed 2 Answers
UI - Scroll through a list of items 0 Answers