ProMouse – Control your mouse position from Unity.

Continuing with my small utility scripts for Unity, I’m releasing ProMouse for Unity, its a set of libraries that lets you control the mouse position within Unity, as Input.mousePosition in the docs is read only. This package works seamlessly across Windows, OSX and linux operating systems.

In order to modify the mouse position I  exposed a simple and small API to move your mouse locally or globally in the Screen.

NOTE: All the global coordinates for this package are relative to the main screen.

For more detailed info on how to use this package, you can also check:

If you are still interested you can also get the package at:


The only class you should access when using this package is the ProMouse


The ProMouse.cs class is a singleton that you can call from anywhere in your
code and exposes the following functions:


// Sets the cursor position to (xPos, yPos) pixel coordinates relative to
// Unity's window.
// The bottom-left of the window/screen(in full screen mode)
// is at (0, 0). the top-right of the window/screen(in full screen mode)
// is at (Screen.width, Screen.height)
public void SetCursorPosition(int xPos, int yPos);

// Sets the cursor position to (xPos, yPos) pixel coordinates relative to
// the main display
// The bottom-left of the main display is at (0, 0) and the top-right of the main display
// is at (ProMouse.Instance.GetMainScreenSize().x, ProMouse.Instance.GetMainScreenSize().y)
// which is your current main display resolution.
public void SetGlobalCursorPosition(int xPos, int yPos);

// Returns the value of the global mouse position relative to the main
// display going from 0,0 on the bottom-left corner of your main display to
// (ProMouse.Instance.GetMainScreenSize().x, ProMouse.Instance.GetMainScreenSize().y)
// on the top-right corner of your main display.
public Vector2 GetGlobalMousePosition();

// Returns the value fo the local mouse position relative to Unity's
// window, this is the same as Input.mousePosition
public Vector2 GetLocalMousePosition();

// returns your main screen resolution, this is the same as calling
// (Screen.currentResolution.width, Screen.currentResolution.height)
public Vector2 GetMainScreenSize();


Example usage. 

In order to access any function of the ProMouse class you just need to type

“ProMouse.Instance.” + the name of the function you want to call.

In example for setting the mouse position at 0,0:

void Start() {

For checking all the functions of the ProMouse class working just refer to
the Example.cs class that comes with the project.


For Advanced users:

ProCursor.cs is a singleton class that creates a hidden GameObject to act as a way
to call a coroutine for moving our mouse as we need to wait one frame in
order to get the updated mouse position.

This coroutine is needed in order to update the mouse position and get the
correct values but you dont need to worry about that, you just need to call:

ProMouse.Instance.SetCursorPosition(pixels on x, pixels on y) or
ProMouse.Instance.SetGlobalCursorPosition(Pixels on x, pixels on y)

Depending on your needs.

In case you need to do an operation between when the mouse gets updated to
the new position after moving the mouse (which only takes one frame), there
is a flag that lets you know if there is an operation being performed on the
mouse and can be accesed like this:

(bool) ProMouse.Instance.MouseBusy; (read-only)

*** *** *** *** *** *** *** ***

The ProMouse package will work straight on any platform natively, but if you are
testing your projects in a virtual machine the mouse position gets internally
updated but you will not see your cursor moved; This is caused because the
virtual machine installs mouse drivers in order to seamlessly go from the
Host OS to the virtualized OS.

So basically what you need to do is to disable the mouse integration with the
virtual machine.

Here are some links you can check regarding vmware but they are not
assured to work: (VMware specific)

Maybe this will work on other virtual machines maybe not, if it
happens to work out of the box in other virtualizing software just share it
in the comments so people can know where it works.

4 Responses to “ProMouse – Control your mouse position from Unity.”

  1. Juan Sebastian says:

    Nope. everything web related is not supported unfortunately due to security constraints

  2. Andrea says:

    Is promouse compatible with webgl builds?

  3. Juan Sebastian says:

    Try to doit by yourself:
    Change the position :).

    On the other hand, yes, Unity *Should* doit by itself, sadly it doesnt :(.

  4. Skipcast says:

    >$20 for a utility class which does something unity really should be able to by itself.

    no thanks