Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Problem with Cursor

Discussion in 'Scripting' started by niick555, Jul 1, 2015.

  1. niick555

    niick555

    Joined:
    Sep 19, 2014
    Posts:
    11
    Good night,
    I'm trying to use the Cursor class, but I'm having problems when using Cursor.lockState and then get the following message: "Assets / MouseLock.js (13.24): BCE0019: 'lockCursor' is not a member of 'UnityEngine.Cursor'."

    I can not understand why the Unity does not recognize the 'lockCursor' as a member of the 'UnityEngine.Cursor "can someone help me? Below is my code. Thanks!

    Code (JavaScript):
    1. #pragma strict
    2.  
    3. var teste : boolean = false;
    4.  
    5. function Start () {
    6.  
    7. }
    8.  
    9. function Update () {
    10.     if(Input.GetKey(KeyCode.Escape) && teste == false)
    11.     {
    12.         Cursor.lockState = CursorLockMode.Locked;
    13.      
    14.         teste = true;
    15.     }
    16. }
     
  2. LeftyRighty

    LeftyRighty

    Joined:
    Nov 2, 2012
    Posts:
    5,148
    that script works perfectly well, copied it into a new js script in my testing project and it's not throwing any errors and appears to be working when i build the project.

    Should also point out that "lockCursor" isn't anywhere in that script... so is this really the script throwing the error? lockCursor is very much not part of the cursor class:

    http://docs.unity3d.com/ScriptReference/Cursor.html

    lockState, Visible and SetCursor() are the only properties and function
     
    niick555 likes this.
  3. niick555

    niick555

    Joined:
    Sep 19, 2014
    Posts:
    11
    I got troubleshoot this error! The problem was my version of Unity. Thank you, but I have one more question: The cursor does not get caught in the middle, but somewhere any of the screen ... How can I do to lock it in the center of the screen? Thanks!
     
  4. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,384