Quantcast
Channel: Questions in topic: "issue"
Viewing all articles
Browse latest Browse all 827

Mouse Cursor Problem

$
0
0
I'm currently attempting to write a script that, when a certain UI element is activated, it will allow the player to press the 'E' key to switch cameras to a camera named cam2. So far I am successful, except for one aspect: The cursor does not show up. I believe that this is due to the fact that the camera is switching from the default FPSController because, when I disable the First Person Controller script in edit mode, the cursor will show up. I tried adding the line: Cursor.visible = true; at the end of the IF statement. By using Debug.Log, I have confirmed that the line of code is executing successfully, but the mouse cursor doesn't appear to actually be appearing once again. I've even attempted to deactivate the FPSController entirely, which I have successfully done so, but the mouse cursor remains invisible. Here's my complete code below: using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class CameraSwitch : MonoBehaviour { public Text activateText; public GameObject Jim; public Camera cam1; public Camera cam2; public GameObject player; // Use this for initialization void Start () { cam1.enabled = true; cam2.enabled = false; } // Update is called once per frame void Update () { if (Input.GetKeyDown("e")) { Debug.Log("E Pressed!"); if (activateText.enabled == true) { cam1.enabled = !cam1.enabled; cam2.enabled = !cam2.enabled; player.SetActive(true); if (cam2.enabled == true) { Cursor.visible = true; Debug.Log("Cursor should be enabled!"); player.SetActive(false); } } } } } Any ideas on how to fix this?

Viewing all articles
Browse latest Browse all 827

Trending Articles



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