Jump to content

[SOLVED] Lock/unlock cursor


photo

Recommended Posts

I have an inventory in the game and I want that when opening this inventory, the mouse becomes free to move, and when the inventory closes, the cursor is fixed in the center of the screen. At the same time, it is desirable that in both cases the cursor is visible.

Link to comment

Hi Zhenya,

Please try to use something like this:

public void SetCursorEnabled(bool enabled)
{
	if (enabled)
	{
		Input.MouseHandle = Input.MOUSE_HANDLE.USER;
		Gui.Get().MouseEnabled = true;
		App.MouseGrab = false;
		App.MouseCursorHide = false;
	}
	else
	{
		Input.MouseHandle = Input.MOUSE_HANDLE.GRAB;
		Gui.Get().MouseCursor = 0;
		App.MouseCursorHide = true;
		App.MouseGrab = true;
		ControlsApp.MouseEnabled = true;
	}
}

Best regards,
Alexander

  • Thanks 1
Link to comment
2 hours ago, alexander said:

Hi Zhenya,

Please try to use something like this:

public void SetCursorEnabled(bool enabled)
{
	if (enabled)
	{
		Input.MouseHandle = Input.MOUSE_HANDLE.USER;
		Gui.Get().MouseEnabled = true;
		App.MouseGrab = false;
		App.MouseCursorHide = false;
	}
	else
	{
		Input.MouseHandle = Input.MOUSE_HANDLE.GRAB;
		Gui.Get().MouseCursor = 0;
		App.MouseCursorHide = true;
		App.MouseGrab = true;
		ControlsApp.MouseEnabled = true;
	}
}

Best regards,
Alexander

Your solution works best. I've already started coming up with excuses for the game - it's retro, get used to it. But you helped me solve this problem.

Link to comment
  • silent changed the title to [SOLVED] Lock/unlock cursor
×
×
  • Create New...