天天看点

UE4中通C++代码获取屏幕鼠标位置

UE4中通C++代码获取屏幕鼠标位置

UWorld * world = GetWorld();
	if (world)
	{
		APlayerController* pc = world->GetFirstPlayerController();
		if (pc)
		{
			ULocalPlayer* LocalPlayer = pc->GetLocalPlayer();
			if (LocalPlayer && LocalPlayer->ViewportClient)
			{
				FVector2D MousePosition;
				if (LocalPlayer->ViewportClient->GetMousePosition(MousePosition))
				{
					UE_LOG(VRSLog, Warning, TEXT("Cursor.position X :  %f , Y : %f"), MousePosition.X, MousePosition.Y);
				}
			}
		}
	}