Answers for "how to get the location of cursor in unity"

C#
26

unity get mouse position

Vector3 worldPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
Posted by: Guest on July-16-2020
3

unity set cursor position

//C#
    // Import
    using System.Runtime.InteropServices;
    
    // Inside class
    [DllImport("user32.dll")]
    static extern bool SetCursorPos(int X, int Y);
    
    // Example
    int xPos = 30, yPos = 1000;   
    SetCursorPos(xPos,yPos);//Call this when you want to set the mouse position
Posted by: Guest on January-06-2022

Code answers related to "how to get the location of cursor in unity"

C# Answers by Framework

Browse Popular Code Answers by Language