Last active
October 28, 2016 11:07
-
-
Save melv-n/65c7494ecbacf11ea4910100d446f54e to your computer and use it in GitHub Desktop.
Revisions
-
Melvin revised this gist
Oct 28, 2016 . 1 changed file with 7 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -12,23 +12,26 @@ void OnGUI() { // When entered with CLICK: Releases Pointer Lock but does not Reveal Cursor. // When entered with Q: Works as intended. Released Pointer Lock and Reveals the Cursor. if (Input.GetKeyDown(KeyCode.O)) { ExitPointerLock(); } // ESC: Exit PointerLock state // When entered with CLICK: Releases Pointer Lock but does not Reveal Cursor. // When entered with Q: On FIRST press it Releases Pointer Lock (cursor still hidden), on SECOND press it Reveals the Cursor! if (Input.GetKeyDown(KeyCode.Escape)) { ExitPointerLock(); } } void EnterPointerLock() { Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; } void ExitPointerLock() { Cursor.lockState = CursorLockMode.None; Cursor.visible = true; } public override void OnPointerDown(UnityEngine.EventSystems.PointerEventData eventData) { EnterPointerLock(); -
Melvin revised this gist
Oct 28, 2016 . 1 changed file with 18 additions and 11 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -3,27 +3,34 @@ public class Main : Button { void OnGUI() { // Q: Enter PointerLock state if (Input.GetKeyDown(KeyCode.Q)) { EnterPointerLock(); } // O: Exit PointerLock state // When entered with CLICK: Releases Pointer Lock but does not Reveal Cursor. // When entered with Q: Works as intended. Released Pointer Lock and Reveals the Cursor. if (Input.GetKeyDown(KeyCode.O)) { Cursor.lockState = CursorLockMode.None; Cursor.visible = true; } // ESC: Exit PointerLock state // When entered with CLICK: Releases Pointer Lock but does not Reveal Cursor. // When entered with Q: On FIRST press it Releases Pointer Lock (cursor still hidden), on SECOND press it Reveals the Cursor! if (Input.GetKeyDown(KeyCode.Escape)) { Cursor.lockState = CursorLockMode.None; Cursor.visible = true; } } void EnterPointerLock() { Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; } public override void OnPointerDown(UnityEngine.EventSystems.PointerEventData eventData) { EnterPointerLock(); } } -
Melvin revised this gist
Oct 28, 2016 . 1 changed file with 15 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,16 +1,29 @@ using UnityEngine; using UnityEngine.UI; public class Main : Button { void OnGUI() { // Exit PointerLock state (works when entered with Q) if (Input.GetKeyDown(KeyCode.O)) { Cursor.lockState = CursorLockMode.None; Cursor.visible = true; } // Enter PointerLock state if (Input.GetKeyDown(KeyCode.Q)) { Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; } // Exit PointerLock state if (Input.GetKeyDown(KeyCode.Escape)) { Cursor.lockState = CursorLockMode.None; Cursor.visible = true; } } public override void OnPointerDown(UnityEngine.EventSystems.PointerEventData eventData) { Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; } } -
Melvin revised this gist
Oct 28, 2016 . 1 changed file with 0 additions and 5 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -3,11 +3,6 @@ using System.Runtime.InteropServices; public class Main : Button { void OnGUI() { if (Input.GetKeyDown(KeyCode.Escape)) { Cursor.lockState = CursorLockMode.None; -
Melvin created this gist
Oct 28, 2016 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ using UnityEngine; using UnityEngine.UI; using System.Runtime.InteropServices; public class Main : Button { #if UNITY_WEBGL [DllImport("__Internal")] private static extern void SendClientHeartbeat(string _msg); #endif 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; } }