- Home /
Self answered. User Error
So i made a pause menu for my game and it works on the first level but doesnt work on any other levels, anyone have any idea as to why this is?
The script that i use for all the buttons in the menu
pragma strict
var pauseKey : KeyCode;
var PauseActive : GameObject;
function Update () {
if (Input.GetKeyUp(pauseKey) && PauseActive.GetComponent(Canvas).enabled == false){
Pause();
}else if (Input.GetKeyUp(pauseKey) && PauseActive.GetComponent(Canvas).enabled == true){
UnPause();
}
}
function Pause () {
PauseActive.GetComponent(Canvas).enabled = true;
Debug.Log("Paused");
Time.timeScale = 0f;
}
function UnPause () {
PauseActive.GetComponent(Canvas).enabled = false;
Debug.Log("Un-paused");
Time.timeScale = 1f;
}
function SaveGame () {
PlayerPrefs.SetInt("LevelNumber", Application.loadedLevel);
Debug.Log("Game has been saved!");
}
on the first level if i press the pauseKey the ui shows up and all the buttons are selectable, if i do it on the second level or any other level it shows the ui but the buttons arent selectable i have it setup in the exact same way on ever scene. if anyone has any ideas how to fix this please let me know as its been frustrating me for 3 days now!
I don't see anything specific to the current level you are. Could you tell us at what game object this script is attached ? On every level.
It is attatched to an empty game object that has the canvas attached to it which is where the buttons are, i put that into a prefab and when i put the prefab into another level the buttons on the menu don't get highlighted when i hover over them or anything :/
Check the GameObject references in Editor's Inspector after loading the second scene. Perhaps they are lost.
they are still there i even deleted and re added them just to make sure :/
Could you share your project, or at least make a very simple project with this problem reproducible, and give us a link to it ?
Answer by SuperReaper1999 · Dec 11, 2014 at 01:49 PM
I fixed the issue, turns out i am stupid and had forgotten about the EventSystem needing to be in the scene. very sorry to have wasted everyone's time.
Follow this Question
Related Questions
A node in a childnode? 1 Answer
How i make this code in Unity Javascript 2 Answers
AI navigating all 6 sides of a cube 0 Answers
using Application.OpenURL for opening new tab? 2 Answers
Vehicle Won't go past 2nd gear. 1 Answer