all repos — RPG @ dd5f6156ac54813c7cb4bff643887514808b3930

Fully functional 3D turn based role playing game coded in C# and base Unity.

add hide cursor logic
Marco Andronaco andronacomarco@gmail.com
Wed, 15 Apr 2020 15:33:18 +0200
commit

dd5f6156ac54813c7cb4bff643887514808b3930

parent

62a0546261098a7868f5986f21adf997f247852f

M Assets/Scripts/Battle/BattleUIManager.csAssets/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.csAssets/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.csAssets/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.csAssets/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; + } + } }