From 62c339f09aa89514466c92f32084de2cddf87a57 Mon Sep 17 00:00:00 2001 From: Lncvrt Date: Wed, 25 Jun 2025 13:36:12 -0700 Subject: [PATCH] Fix being able to edit the ui when not paused --- Assets/Scripts/GamePlayer.cs | 1 + Assets/Scripts/GamePlayerPauseMenu.cs | 29 ++++++++++++++++++--------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/Assets/Scripts/GamePlayer.cs b/Assets/Scripts/GamePlayer.cs index e444d74..58803ca 100644 --- a/Assets/Scripts/GamePlayer.cs +++ b/Assets/Scripts/GamePlayer.cs @@ -715,6 +715,7 @@ public class GamePlayer : MonoBehaviour Cursor.lockState = CursorLockMode.Locked; backgroundMusic.Play(); pausePanel.SetActive(false); + if (GamePlayerPauseMenu.Instance.editingUI == true) GamePlayerPauseMenu.Instance.ToggleEditingUI(); } void OnApplicationPause(bool pause) diff --git a/Assets/Scripts/GamePlayerPauseMenu.cs b/Assets/Scripts/GamePlayerPauseMenu.cs index 38602ea..c6786a9 100644 --- a/Assets/Scripts/GamePlayerPauseMenu.cs +++ b/Assets/Scripts/GamePlayerPauseMenu.cs @@ -4,6 +4,7 @@ using UnityEngine.UI; public class GamePlayerPauseMenu : MonoBehaviour { + public static GamePlayerPauseMenu Instance; public Button backButton; public Button continueButton; public Button editUiButton; @@ -15,9 +16,11 @@ public class GamePlayerPauseMenu : MonoBehaviour public TMP_Text scoreText; public TMP_Text highScoreText; public TMP_Text boostText; + public bool editingUI = false; void Awake() { + Instance = this; musicSlider.value = PlayerPrefs.GetFloat("musicVolume", 1f); sfxSlider.value = PlayerPrefs.GetFloat("sfxVolume", 1f); backButton.onClick.AddListener(async () => @@ -38,16 +41,7 @@ public class GamePlayerPauseMenu : MonoBehaviour }); editUiButton.onClick.AddListener(() => { - musicSlider.gameObject.SetActive(!musicSlider.gameObject.activeSelf); - sfxSlider.gameObject.SetActive(!sfxSlider.gameObject.activeSelf); - backButton.gameObject.SetActive(!backButton.gameObject.activeSelf); - continueButton.gameObject.SetActive(!continueButton.gameObject.activeSelf); - editUiButton.transform.GetChild(0).GetComponent().text = editUiButton.transform.GetChild(0).GetComponent().text == "Edit UI" ? "Done" : "Edit UI"; - resetUiButton.gameObject.SetActive(!resetUiButton.gameObject.activeSelf); - fpsText.GetComponent().canDrag = !fpsText.GetComponent().canDrag; - scoreText.GetComponent().canDrag = !scoreText.GetComponent().canDrag; - highScoreText.GetComponent().canDrag = !highScoreText.GetComponent().canDrag; - boostText.GetComponent().canDrag = !boostText.GetComponent().canDrag; + ToggleEditingUI(); }); resetUiButton.onClick.AddListener(() => { @@ -61,4 +55,19 @@ public class GamePlayerPauseMenu : MonoBehaviour PlayerPrefs.DeleteKey("DraggedUIBoostText"); }); } + + public void ToggleEditingUI() + { + editingUI = !editingUI; + musicSlider.gameObject.SetActive(!musicSlider.gameObject.activeSelf); + sfxSlider.gameObject.SetActive(!sfxSlider.gameObject.activeSelf); + backButton.gameObject.SetActive(!backButton.gameObject.activeSelf); + continueButton.gameObject.SetActive(!continueButton.gameObject.activeSelf); + editUiButton.transform.GetChild(0).GetComponent().text = editUiButton.transform.GetChild(0).GetComponent().text == "Edit UI" ? "Done" : "Edit UI"; + resetUiButton.gameObject.SetActive(!resetUiButton.gameObject.activeSelf); + fpsText.GetComponent().canDrag = !fpsText.GetComponent().canDrag; + scoreText.GetComponent().canDrag = !scoreText.GetComponent().canDrag; + highScoreText.GetComponent().canDrag = !highScoreText.GetComponent().canDrag; + boostText.GetComponent().canDrag = !boostText.GetComponent().canDrag; + } } \ No newline at end of file