How to fix a bug with UE5.1 which causes the mouse cursor to become hidden

I also use CommonUI and have encountered this same issue. In my case I have a custom class that replaces CommonUI’s CommonAnalogCursor with some extra functionality. Among them is the fact I wanted the cursor to be hidden when using keyboard navigation (Arrows/WASD). The solution to always show the cursor using the CVAR didn’t seems like a good fix to me.

I did find a kinda permanent solution however: Create a custom GameInstance class or open the one you already have, and override FinishDestroy() function, which is called before the GameInstance is destroyed (At the end of the game or PIE session).

CustomGameInstance.h

public:
    virtual void FinishDestroy() override;

CustomGameInstance.cpp

void USMRGameInstance::FinishDestroy()
{
	if (FSlateApplication::IsInitialized())
	{
		const TSharedPtr<FSlateUser> SlateUser = FSlateApplication::Get().GetUser(FSlateApplication::Get().GetCursorUser()->GetUserIndex());
		if (SlateUser)
		{
			SlateUser->SetCursorVisibility(true);
		}
	}

	Super::FinishDestroy();
}

I tried to do the same in a GameInstance Blueprint but I don’t see a way to access Slate API. Trying to call SetShowMouseCursor from the PlayerController also isn’t viable as it wasn’t valid during the “shutdown“ event.

I guess it could be done during the destruction of the PlayerController itself but you have to make sure you add this code every time you create another PlayerController class.

Hope this helps. Normally CommonUI should handle this bug already, it’s 5.7 and still not fixed.

1 Like