- Home /
Mouse cursor - Please Help
Hi, i have problem with mouse cursor, it is invisible in start, and i want that it appears when i press ecs button, i made this script :
static var showCursor :bool ;
function Start () {
Screen.showCursor = false;
}
function Update () {
if( Input.GetKey(KeyCode.Escape));
Screen.showCursor = true;
}
but is showing me this error: Assets/Player.js(2,25): BCE0018: The name 'bool' does not denote a valid type ('not found').
Can anybody help me?
Answer by deltamish · Dec 31, 2013 at 02:54 PM
Hi try this
#pragma strict //Add this very Important
public var ShowCursor:boolean = false; // <-- See changes i made cahnged from bool(C# syntax) to boolean(JS syntax)
function Start () {
Screen.showCursor = false;
Screen.lockCursor = true;
}
function Update () {
if( Input.GetKeyDown(KeyCode.Escape))// <-- Dont add ; at end of an if statement
{
ShowCursor = !ShowCursor;//Toggle
}
Screen.showCursor = ShowCursor;
Screen.lockCursor = !ShowCursor;///set lock to false when mouse cursor enaled and vice versa
}
none of these doesnt work, i want to it work in .exe file, bcs when i press esc it shows menu but i cant press anything :(
did you try pressing Escape again and again i am sure that this script works as i am using it in my current project as well
i tried now, but it still doesnt work, i dont know if this is important, but my script doesnt show any conection between these 3 ShowCursor
what do you mean by
conection between these 3 ShowCursor
I dont know, it is stupid, i noticed that if some word is on more playes if u press on one of them it shows and others with backround color, and in your script ShowCursor is colored, and $$anonymous$$e is not, but its stupid, I dont know is it maybe bcs I think I did something for cursor in my another script, so i will now try to erase it
Answer by sparkzbarca · Dec 31, 2013 at 02:27 PM
static var showCursor :bool ;
get rid of that line.
Answer by RudyButzke · Dec 31, 2013 at 02:58 PM
var showCursor :boolean;
function Start () {
Screen.showCursor = false;
}
function Update () {
if( Input.GetKey(KeyCode.Escape));
Screen.showCursor = true;
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613125228im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Codes unavailable in C# 0 Answers
Why is Unity deleting my prefabs!? 1 Answer
2D Border doesnt allow the nutbomb gameobject to bounce 0 Answers
Object reference not set to an instance of an object 0 Answers
camera movments fixed.. character controller without using character controller -.-' 2 Answers