Last active
February 23, 2018 08:35
-
-
Save AdamCarballo/78425154092380cb646111640df120c0 to your computer and use it in GitHub Desktop.
Unity - Switch the current cursor mode, including Cursor.visible() and Cursor.lockState() in one function.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using UnityEngine; | |
| public class CursorMode { | |
| /// <summary> | |
| /// Switch the current cursor mode to enabled, including Cursor.visible(true) and Cursor.lockState(None). | |
| /// </summary> | |
| public static void Enable() { | |
| Cursor.visible = true; | |
| Cursor.lockState = CursorLockMode.None; | |
| } | |
| /// <summary> | |
| /// Switch the current cursor mode to disabled, including Cursor.visible(false) and Cursor.lockState(Locked). | |
| /// </summary> | |
| public static void Disable() { | |
| Cursor.visible = false; | |
| Cursor.lockState = CursorLockMode.Locked; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment