using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour
{
public GameObject particle;
void Update()
{
if (Input.GetButtonDown("Fire1"))
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray))
Instantiate(particle, transform.position, transform.rotation);
}
}
}
//the object to move
public Transform objectToMove;
void Update()
{
Vector3 mouse = Input.mousePosition;
Ray castPoint = Camera.main.ScreenPointToRay(mouse);
RaycastHit hit;
if (Physics.Raycast(castPoint, out hit, Mathf.Infinity))
{
objectToMove.transform.position = hit.point;
}
}
Or if you're looking for more specifically an OS API implementation, not necessarily for unity, check Getting "global" mouse position in Mac OS X
Not to be that guy, but at least try to google it before making a question thread. These where all top google results.
Taken from https://docs.unity3d.com/ScriptReference/Input-mousePosition.html
or taken from https://stackoverflow.com/a/46999239/12808204
Or if you're looking for more specifically an OS API implementation, not necessarily for unity, check Getting "global" mouse position in Mac OS X Not to be that guy, but at least try to google it before making a question thread. These where all top google results.