Hey there, I have a little big question.
I am a big noob so I need some help with it.
In my first scene I have the main menu.
When I press the Start Button, it destroys this scene and
loads an other scene, the ingame scene.
So now I want the following things to happen:
- When I pres ESC the ingame scene should be paused
(maybe with “Time.timeScale = 0;”). - The main menu scene should be loaded. The ingame Scene should not be destroyed.
- When I press Escape again the main menu scene should be destroyed,
it should go back to the ingame scene and the Game should be unpaused
(“Time.timeScale = 1;”).
Right now, this is my (uncomplete) code:
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
public class ButtonManagerIngame : MonoBehaviour {
bool Pause = false;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
public void PausiereSpiel(string PauseGameLevel, string newGameLevel)
{
if (Input.GetKeyDown ("escape")) {
if(Pause == true){
Time.timeScale = 1.0f;
SceneManager.LoadScene(newGameLevel);
Pause = false;
} else {
Time.timeScale = 0.0f;
Pause = true;
DontDestroyOnLoad(transform.PauseGameLevel);
}
}
}
}
Anyway I get compiler errors, but I don’t think it works this way…
Can anyone help me?
The Reason why I want a scene and not a canvas is, that I am not
so good in Unity and I already have a finished Main menu scene I want to use for now.