- Home /
Question by
Jacooboo · Oct 13, 2017 at 01:46 PM ·
cursorlock-cursorcursor-customization
How can i make the cursor to only show when i press escape and my IN game menu opens?
I made an IN game menu and i want the cursor to show just when i open the menu, i don't want it to show when i'm in gameplay. Here is screenshots of the gameplay: https://imgur.com/a/AltBG
I also post my script here in text mode.
using UnityEngine; using System.Collections;
public class InGameMenu : MonoBehaviour { public Transform canvas;
// Update is called once per frame
void Update () {
if (Input.GetKeyDown(KeyCode.Escape))
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
if (Input.GetKeyDown(KeyCode.Escape))
{
if (canvas.gameObject.activeInHierarchy == false)
{
canvas.gameObject.SetActive (true);
} else
{
canvas.gameObject.SetActive (false);
}
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Artifacts on cursor when using CursorMode.Auto 0 Answers
Trouble with unlocking cursor 1 Answer
Glue mouse to object 2 Answers
Cursor.LockState = CursorLockMode.Locked doasnt works. 0 Answers
Cursor Resize? 1 Answer