montzions ui pausenmenü ui lebns ui nachladen pausen menü neues digsein
This commit is contained in:
@@ -1,51 +1,53 @@
|
||||
//Oliver
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class PausenManager : MonoBehaviour
|
||||
{
|
||||
private bool isOn = false;
|
||||
[SerializeField] GameObject Can;
|
||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||
void Start()
|
||||
{
|
||||
Can.SetActive(false);
|
||||
}
|
||||
// Damit andere Skripte (wie deine Waffe) wissen, ob pausiert ist
|
||||
public static bool GameIsPaused = false;
|
||||
|
||||
// Ziehe dein Pause-Menü UI-Panel hier im Inspector rein
|
||||
public GameObject pauseMenuUI;
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Escape))
|
||||
{
|
||||
isOn = true;
|
||||
show();
|
||||
if (GameIsPaused)
|
||||
{
|
||||
Resume();
|
||||
}
|
||||
else
|
||||
{
|
||||
Pause();
|
||||
}
|
||||
}
|
||||
}
|
||||
public void show()
|
||||
|
||||
public void Resume()
|
||||
{
|
||||
if(isOn = true)
|
||||
{
|
||||
Can.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Can.SetActive(false);
|
||||
}
|
||||
pauseMenuUI.SetActive(false);
|
||||
Time.timeScale = 1f; // Zeit läuft wieder normal
|
||||
GameIsPaused = false;
|
||||
|
||||
// Maus wieder verstecken und im Spiel festhalten
|
||||
Cursor.visible = false;
|
||||
Cursor.lockState = CursorLockMode.Locked;
|
||||
}
|
||||
public void going()
|
||||
|
||||
void Pause()
|
||||
{
|
||||
Can.SetActive(false);
|
||||
show();
|
||||
pauseMenuUI.SetActive(true);
|
||||
Time.timeScale = 0f; // Spiel friert ein
|
||||
GameIsPaused = true;
|
||||
|
||||
// Maus anzeigen und entsperren, damit du klicken kannst
|
||||
Cursor.visible = true;
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
}
|
||||
public void lobby (string sceneName)
|
||||
|
||||
public void QuitGame()
|
||||
{
|
||||
SceneManager.LoadScene(sceneName);
|
||||
Debug.Log("Spiel wird verlassen...");
|
||||
Application.Quit(); // Beendet das Spiel (funktioniert nur im fertigen Build, nicht im Editor)
|
||||
}
|
||||
public void Quit()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
UnityEditor.EditorApplication.isPlaying = false;
|
||||
#else
|
||||
Application.Quit();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user