Skip to content

Instantly share code, notes, and snippets.

@AdamCarballo
Last active February 23, 2018 08:35
Show Gist options
  • Select an option

  • Save AdamCarballo/78425154092380cb646111640df120c0 to your computer and use it in GitHub Desktop.

Select an option

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.
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