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. Dismiss Notice

ScreenCursor' code no longer working in 4.6.3

Discussion in 'Scripting' started by cristo, Apr 3, 2015.

  1. cristo

    cristo

    Joined:
    Dec 31, 2013
    Posts:
    265
    Hi,

    I had some code to restrict cursor movement that worked well in a earlier version of unity, but trying to use it in 4.6.3 makes it throw up an error:

    Assets/Level1_Scripts/Restric_Cursor.cs(9,25): error CS0103: The name `ScreenCursor' does not exist in the current context

    Monodevelop doesn't like the line:

    ScreenCursor.SimulateMove

    I'm not sure what's going wrong because it used to work. Any feed back would be great!



    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class Restric_Cursor : MonoBehaviour {
    5.     public Vector2 RectSize;
    6.     public bool Visible;
    7.     void Update () {
    8.         if (!new Rect(Screen.width/2-RectSize.x/2,Screen.height/2-RectSize.y/2,RectSize.x,RectSize.y).Contains(Input.mousePosition)) {
    9.             ScreenCursor.SimulateMove(new Vector2(Screen.width/2,Screen.height/2),0.2f,true);
    10.         }
    11.     }
    12.     void OnGUI() {
    13.         if (Visible) {
    14.             GUI.Box(new Rect(Screen.width/2-RectSize.x/2,Screen.height/2-RectSize.y/2,RectSize.x,RectSize.y),"");
    15.         }}
    16. }
     
  2. schmidicow

    schmidicow

    Joined:
    Mar 23, 2014
    Posts:
    10
    I think you have to declare what ScreenCursor is, like you did with Rectsize and Visible. (public Vector2 RectSize; )