So this is really wierd but whenever i try to put down a beutifull Input.GetMouseButtonDown it never works…
ive never encountered something like this before and its kinda a pain but i cant seem to fix it. and if i print the output it always says false.
my code looks something like this
private void Update()
{
if (cursor != null && Camera.current != null)
{
var x = Camera.current.ScreenToWorldPoint(Input.mousePosition);
Vector2Int pos = new Vector2Int(Mathf.RoundToInt(x.x), Mathf.RoundToInt(x.y));
cursor.position = new Vector3(pos.x, pos.y, transform.position.z);
if (Input.GetMouseButtonDown(0))
{
print("omg");
}
}
}
Camera.current is only set during rendering and could change depending on the context. You should not use it in Update which is pre-rendering. Also Camera.current could even reference the internal camera of the scene view inside the editor, again all depending on the context. In multi-camera rendering setups (like VR) Camera.current may reference either the left or right eye, again depending on the context.
So as @zulo3d said, in most cases you would use Camera.main or setup a public Camera variable and assign the camera you want to use.