add hide cursor logic
Marco Andronaco andronacomarco@gmail.com
Wed, 15 Apr 2020 15:33:18 +0200
5 files changed,
13 insertions(+),
0 deletions(-)
M
Assets/Scripts/Battle/BattleUIManager.cs
→
Assets/Scripts/Battle/BattleUIManager.cs
@@ -33,6 +33,7 @@ public GameObject items_panel;
private void Start() { + UI.showCursor(true); gm = GameMaster.Instance; battle = GetComponent<BattleManager>();
M
Assets/Scripts/Menu/MenuManager.cs
→
Assets/Scripts/Menu/MenuManager.cs
@@ -22,6 +22,7 @@ Panel currentPanel = Panel.None;
private void Start() //remember this is shared between gameover and main menu { + UI.showCursor(true); //set music menu mixer.SetFloat("MusicVolume", Mathf.Log10(PlayerPrefs.GetFloat("MusicVolume", 0.75f)) * 20); mixer.SetFloat("SfxVolume", Mathf.Log10(PlayerPrefs.GetFloat("SfxVolume", 0.75f)) * 20);
M
Assets/Scripts/Overworld/OverworldUIManager.cs
→
Assets/Scripts/Overworld/OverworldUIManager.cs
@@ -41,9 +41,11 @@ {
hideAllPanels(); if (onOff) { + UI.showCursor(true); pause_panel.SetActive(true); } else { + UI.showCursor(false); currentPanel = 0; pause_panel.SetActive(false); }
M
Assets/Scripts/Utility/UI.cs
→
Assets/Scripts/Utility/UI.cs
@@ -183,4 +183,13 @@ tmpmp.GetComponent<Text>().text = (int)s.MP + "/" + (int)s.MaxMP + " MP";
tmpmp.GetComponentInChildren<Slider>().value = (float)(s.MP / s.MaxMP); } } + + public static void showCursor(bool toggle){ + Cursor.visible = toggle; + if(toggle){ + Cursor.lockState = CursorLockMode.None; + } else { + Cursor.lockState = CursorLockMode.Locked; + } + } }