- Home /
Question by
vickyboo · Jun 21, 2018 at 10:06 PM ·
scripting problemerrorbeginnerbasic
main menu not loading level 1 please help beginner here
Hello! I am trying to figure this out because it was working and now that I am done with my game it wont play level 1 :( I get this error "ArgumentException: Input Button Submit is not setup."
I will include my main menu script:
using UnityEngine.SceneManagement;
using UnityEngine;
using System.Collections;
public class MainMenu : MonoBehaviour {
public GUISkin skin;
void OnGUI()
{
GUI.skin = skin;
GUI.Label (new Rect (10,10, 400,45), "Go Home");
if (PlayerPrefs.GetInt("Level Completed") > 0)
{
if (GUI.Button(new Rect(10, 60, 100, 45), "Play"))
{
SceneManager.LoadScene(PlayerPrefs.GetInt("Level Completed"));
SceneManager.LoadScene(0);
}
}
if (GUI.Button(new Rect(10, 60, 100, 45), "Play"))
{
PlayerPrefs.SetInt("Level Completed", 0);
SceneManager.LoadScene(0);
}
if (GUI.Button (new Rect (10, 210, 100, 45), "Quit"))
{
Application.Quit();
}
}
}
THIS IS MY GAME MANAGER
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
public class GameManager : MonoBehaviour
{
// Count
public int currentScore;
public int highscore;
public int token;
public int tokenCount;
private int totalTokenCount;
public int currentLevel = 0;
public int unlockedLevel;
//Timer Variables
public Rect timerRect;
public Color warningColorTimer;
public Color defaultColorTimer;
public float startTime;
private string currentTime;
//References
public GameObject tokenParent;
void Update()
{
startTime -= Time.deltaTime;
currentTime = string.Format("{0:0.0}", startTime);
if (startTime <= 0)
{
startTime = 0;
Destroy(gameObject);
SceneManager.LoadScene(0);
}
}
void Start()
{
totalTokenCount = tokenParent.transform.childCount;
if (PlayerPrefs.GetInt("Level Completed") > 0)
{
currentLevel = PlayerPrefs.GetInt("Level Completed");
} else {
currentLevel = 0;
}
//DontDestroyOnLoad(gameObject);
}
public void CompleteLevel()
{
if (currentLevel < 3)
{
currentLevel += 3;
PlayerPrefs.SetInt("Level Completed", currentLevel);
PlayerPrefs.SetInt("Level " + currentLevel.ToString() + " score ", currentScore);
SceneManager.LoadScene(currentLevel);
} else {
print("You Win!");
}
}
public void AddToken()
{
tokenCount += 1;
}
//GUI SKI
public GUISkin skin;
private void OnGUI()
{
GUI.skin = skin;
if (startTime < 5f)
{
skin.GetStyle("Timer").normal.textColor = warningColorTimer;
} else {
skin.GetStyle("Timer").normal.textColor = defaultColorTimer;
}
GUI.Label(timerRect, currentTime, skin.GetStyle ("Timer"));
GUI.Label(new Rect(45, 100, 200, 200), tokenCount.ToString() + "/" + totalTokenCount.ToString());
}
}
Comment