Quantcast
Channel: Questions in topic: "lockcursor"
Viewing all articles
Browse latest Browse all 92

Cursor.LockState = CursorLockMode.Locked doasnt works.

$
0
0
i wanted to create a pause menu screen and make it when it is on the cursor lock mode is in none and when the menu is off the cursor is locked, but when i try to lock exiting from the menu it doasnt locks. here is my code: using UnityEngine; using System.Collections; using System.Text; using UnityEngine.UI; namespace UnityStandardAssets.ImageEffects { public class PAUSEMENU : MonoBehaviour { public GameObject menu; public Slider sensitivity; public Text S_Value; void Start() { Cursor.visible = false; Cursor.lockState = CursorLockMode.Locked; //<- here works } void Update() { Debug.Log(Cursor.lockState); Blur effect1 = GetComponentInChildren(); Tonemapping effect2 = GetComponentInChildren(); MouseLook camov = GetComponent(); camov.sensitivityX = sensitivity.value; camov.sensitivityY = sensitivity.value; S_Value.text = "" + sensitivity.value; if (Input.GetKeyDown(KeyCode.Escape)) { if (Time.timeScale == 1)//pause ON { Time.timeScale = 0; menu.active = true; Cursor.lockState = CursorLockMode.None; Cursor.visible = true; effect1.enabled = true; effect2.enabled = true; camov.active = false; } else if (Time.timeScale == 0)// pause OFF { Time.timeScale = 1; menu.active = false; Cursor.lockState = CursorLockMode.Locked; //<-- but here no Cursor.visible = false; effect1.enabled = false; effect2.enabled = false; camov.active = true; } } } } }

Viewing all articles
Browse latest Browse all 92

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>