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

Set Cursor Sensitivity [System Cursor]

Discussion in 'Assets and Asset Store' started by NightmarexGR, Apr 23, 2018.

  1. NightmarexGR

    NightmarexGR

    Joined:
    Jun 7, 2012
    Posts:
    217
    Welcome to the "Set Cursor Sensitivity" Unity Asset.

    Summary:
    "Set Cursor Sensitivity" is an Unity Plugin that gives you the ability to control the actual sensitivity of your Hardware (OS) Cursor in your screen via Scripting.
    You can set a different sensitivity for inside or outside the unity window, you can even create areas with different cursor sensitivity (cursor speed).
    The package comes with an Example Scene to help you start and understand its use.
    Can be combined with Unity's current API to achieve great effects !
    Supports: Unity 3x,4x,5x,2017x

    What you actually get:
    ~Source Code
    ~Forum/Email support
    (As far as its possible and related to the plugin)
    ~New Scripting API.
    -SystemCursor.ResetSensitivity();
    -SystemCursor.ResetSensitivity(int Speed);
    -SystemCursor.SetSensitivity(int Speed);
    -SystemCursor.SetGlobalSensitivity(int Speed);
    -SystemCursor.GetGlobalSensitivity();
    -SystemCursor.SetLocalSensitivity(int Speed);
    -SystemCursor.GetLocalSensitivity();
    -SystemCursor.SetCustomSensitivity(int Speed);
    -SystemCursor.GetCurrentCustomSensitivity();
    -SystemCursor.GetCurrentSensitivity();


    Notes:
    Works outside of the unity window too, and Global sensitivity will not automatically reset after you close the window.
    Works on both Unity Pro and free, but this is a windows only plugin.

    API Documentation:
    --------------------------------------------------------------
    -SystemCursor.ResetSensitivity();
    Resets cursor sensitivity to 8. Values range from 1 to 20
    --------------------------------------------------------------
    -SystemCursor.ResetSensitivity(int Speed);
    Resets cursor sensitivity to "Speed", values restrictions still apply.
    --------------------------------------------------------------
    -SystemCursor.SetSensitivity(int Speed);
    Sets Global Local and Custom sensitivity speeds to "Speed", in other words overrides every other value to set a new speed everywhere. (Even outside the unity window)
    --------------------------------------------------------------
    -SystemCursor.SetGlobalSensitivity(int Speed);
    Sets Global sensitivity to "Speed", the cursors new sensitivity will take effect ONLY outside the unity window. Inside the window and inside custom areas speed will remain as it was.
    --------------------------------------------------------------
    -SystemCursor.GetGlobalSensitivity();
    Returns current Global mouse Sensitivity as an integer.
    --------------------------------------------------------------
    -SystemCursor.SetLocalSensitivity(int Speed);
    Will set the Cursor sensitivity to "Speed" but this effect will only take place inside the unity window. Outside the window (and inside custom zones) the old speed will be preserved.
    --------------------------------------------------------------
    -SystemCursor.GetLocalSensitivity();
    Returns current Local mouse sensitivity as an integer.
    --------------------------------------------------------------
    -SystemCursor.SetCustomSensitivity(int Speed);
    Now this is tricky, this function is used to create custom areas, zones or speed effects. What you must do is call this function with "Speed" as you desired new sensitivity and after that
    whenever you call this "SystemCursor.InsideCustomArea = true" the speed will take effect (only inside unity window) but remember when you want to "SystemCursor.InsideCustomArea = false".
    --------------------------------------------------------------
    -SystemCursor.GetCurrentCustomSensitivity();
    Returns current Custom mouse sensitivity as an integer.
    --------------------------------------------------------------
    -SystemCursor.GetCurrentSensitivity();
    Returns current mouse sensitivity as an integer.
    --------------------------------------------------------------
    --------------------------------------------------------------



    VIDEO : Coming soon

    ASSET STORE : SOON


    Contact Info :
    Email : DarknessBlade.Original@gmail.com
    Youtube :
     
    Last edited: Apr 23, 2018
  2. Jean-Carlos-Gregolon

    Jean-Carlos-Gregolon

    Joined:
    May 26, 2014
    Posts:
    6
    Hey there,
    Got the asset from the Asset Store but I'm having some troubles to use it.
    I'm using the SetLocalSensitivity method as described at the API, but it's changing the global value, so when I do close the application, it remains this value on Windows.
    As described above:
    "Works outside of the unity window too, and Global sensitivity will not automatically reset after you close the window."
    That's the behaviour I got using the Local method.
    I'm using Unity 2018.3.5f1.

    I could save the default value somehow and reaply it when closing the game window, but it wouldn't prevent this side effect if the user close the game process.

    Is there anything I'm missing or it is how it is supposed to work?

    UPDATE: in the editor the "local" option does work, it just does not on a build. I've tryed x64 and x86, both got the same result.

    UPDATE 2:
    Actually, it didn't work on the editor as well, it just change the speed when exit the screen area.
    Anyway, did a work around changing the speed on "OnApplicationQuit" and on "OnApplicationFocus", so if the player open the task manager, will already be at the default speed.

    Thanks in advance.
     
    Last edited: Aug 1, 2019
  3. NightmarexGR

    NightmarexGR

    Joined:
    Jun 7, 2012
    Posts:
    217
    Does the demo scene work for you ?
    If not just make sure you have followed the instructions and changed .NET to 4.0
    unnamed.png
    Also i state "Works outside of the unity window too, and Global sensitivity will not automatically reset after you close the window." Basically you are right, global and local is the same thing in the background. So when you close unity window the last speed you had will be applied to all windows. In my projects I use OnApplicationQuit to make sure i reset the speed in the end.
     
  4. ShidaPenns

    ShidaPenns

    Joined:
    May 9, 2013
    Posts:
    11
    How does this handle crashes/forced closes? I don't want it to affect the outside game sensitivity at all.
     
    Last edited: Feb 20, 2023
  5. NightmarexGR

    NightmarexGR

    Joined:
    Jun 7, 2012
    Posts:
    217
    It does not handle crashes/forced closes, only normal closes. If your program crashes, sadly the OS sensitivity will not restore itself and you will have to manually edit it from the control panel of you OS.
     
    ShidaPenns likes this.
  6. ShidaPenns

    ShidaPenns

    Joined:
    May 9, 2013
    Posts:
    11
    It's a shame but good plugin regardless, thanks.
     
    NightmarexGR likes this.