Fix being able to edit the ui when not paused
This commit is contained in:
@@ -715,6 +715,7 @@ public class GamePlayer : MonoBehaviour
|
|||||||
Cursor.lockState = CursorLockMode.Locked;
|
Cursor.lockState = CursorLockMode.Locked;
|
||||||
backgroundMusic.Play();
|
backgroundMusic.Play();
|
||||||
pausePanel.SetActive(false);
|
pausePanel.SetActive(false);
|
||||||
|
if (GamePlayerPauseMenu.Instance.editingUI == true) GamePlayerPauseMenu.Instance.ToggleEditingUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnApplicationPause(bool pause)
|
void OnApplicationPause(bool pause)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using UnityEngine.UI;
|
|||||||
|
|
||||||
public class GamePlayerPauseMenu : MonoBehaviour
|
public class GamePlayerPauseMenu : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
public static GamePlayerPauseMenu Instance;
|
||||||
public Button backButton;
|
public Button backButton;
|
||||||
public Button continueButton;
|
public Button continueButton;
|
||||||
public Button editUiButton;
|
public Button editUiButton;
|
||||||
@@ -15,9 +16,11 @@ public class GamePlayerPauseMenu : MonoBehaviour
|
|||||||
public TMP_Text scoreText;
|
public TMP_Text scoreText;
|
||||||
public TMP_Text highScoreText;
|
public TMP_Text highScoreText;
|
||||||
public TMP_Text boostText;
|
public TMP_Text boostText;
|
||||||
|
public bool editingUI = false;
|
||||||
|
|
||||||
void Awake()
|
void Awake()
|
||||||
{
|
{
|
||||||
|
Instance = this;
|
||||||
musicSlider.value = PlayerPrefs.GetFloat("musicVolume", 1f);
|
musicSlider.value = PlayerPrefs.GetFloat("musicVolume", 1f);
|
||||||
sfxSlider.value = PlayerPrefs.GetFloat("sfxVolume", 1f);
|
sfxSlider.value = PlayerPrefs.GetFloat("sfxVolume", 1f);
|
||||||
backButton.onClick.AddListener(async () =>
|
backButton.onClick.AddListener(async () =>
|
||||||
@@ -38,16 +41,7 @@ public class GamePlayerPauseMenu : MonoBehaviour
|
|||||||
});
|
});
|
||||||
editUiButton.onClick.AddListener(() =>
|
editUiButton.onClick.AddListener(() =>
|
||||||
{
|
{
|
||||||
musicSlider.gameObject.SetActive(!musicSlider.gameObject.activeSelf);
|
ToggleEditingUI();
|
||||||
sfxSlider.gameObject.SetActive(!sfxSlider.gameObject.activeSelf);
|
|
||||||
backButton.gameObject.SetActive(!backButton.gameObject.activeSelf);
|
|
||||||
continueButton.gameObject.SetActive(!continueButton.gameObject.activeSelf);
|
|
||||||
editUiButton.transform.GetChild(0).GetComponent<TMP_Text>().text = editUiButton.transform.GetChild(0).GetComponent<TMP_Text>().text == "Edit UI" ? "Done" : "Edit UI";
|
|
||||||
resetUiButton.gameObject.SetActive(!resetUiButton.gameObject.activeSelf);
|
|
||||||
fpsText.GetComponent<DraggableUI>().canDrag = !fpsText.GetComponent<DraggableUI>().canDrag;
|
|
||||||
scoreText.GetComponent<DraggableUI>().canDrag = !scoreText.GetComponent<DraggableUI>().canDrag;
|
|
||||||
highScoreText.GetComponent<DraggableUI>().canDrag = !highScoreText.GetComponent<DraggableUI>().canDrag;
|
|
||||||
boostText.GetComponent<DraggableUI>().canDrag = !boostText.GetComponent<DraggableUI>().canDrag;
|
|
||||||
});
|
});
|
||||||
resetUiButton.onClick.AddListener(() =>
|
resetUiButton.onClick.AddListener(() =>
|
||||||
{
|
{
|
||||||
@@ -61,4 +55,19 @@ public class GamePlayerPauseMenu : MonoBehaviour
|
|||||||
PlayerPrefs.DeleteKey("DraggedUIBoostText");
|
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<TMP_Text>().text = editUiButton.transform.GetChild(0).GetComponent<TMP_Text>().text == "Edit UI" ? "Done" : "Edit UI";
|
||||||
|
resetUiButton.gameObject.SetActive(!resetUiButton.gameObject.activeSelf);
|
||||||
|
fpsText.GetComponent<DraggableUI>().canDrag = !fpsText.GetComponent<DraggableUI>().canDrag;
|
||||||
|
scoreText.GetComponent<DraggableUI>().canDrag = !scoreText.GetComponent<DraggableUI>().canDrag;
|
||||||
|
highScoreText.GetComponent<DraggableUI>().canDrag = !highScoreText.GetComponent<DraggableUI>().canDrag;
|
||||||
|
boostText.GetComponent<DraggableUI>().canDrag = !boostText.GetComponent<DraggableUI>().canDrag;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user