Skip to content

Instantly share code, notes, and snippets.

@melv-n
Last active October 28, 2016 11:07
Show Gist options
  • Select an option

  • Save melv-n/65c7494ecbacf11ea4910100d446f54e to your computer and use it in GitHub Desktop.

Select an option

Save melv-n/65c7494ecbacf11ea4910100d446f54e to your computer and use it in GitHub Desktop.
using UnityEngine;
using UnityEngine.UI;
using System.Runtime.InteropServices;
public class Main : Button {
void OnGUI() {
if (Input.GetKeyDown(KeyCode.Escape)) {
Cursor.lockState = CursorLockMode.None;
Cursor.visible = false;
}
}
public override void OnPointerDown(UnityEngine.EventSystems.PointerEventData eventData) {
Cursor.lockState = CursorLockMode.Locked;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment