Hi.
I am working on a demo.
I want to make a combo box to select a resolution and set it.
I get the resolutions array with RHIGetAvailableResolutions();
And I use UGameUserSettings->SetScreenResolution() to set it.
It can not set up most resolutions.
But I can use the command to set the resolution, just like “r.setres 1024x768”.
Can anyone tell me why?
Here is my code:
void UDemoBlueprintLibrary::SetCustomResolution(const FString& InStr)
{
UGameUserSettings* Settings = GEngine->GetGameUserSettings();
FString TempStr = ClearResolutionString(InStr);
int32 StrIdx = TempStr.Find("*");
if (StrIdx != INDEX_NONE)
{
if (Settings)
{
int32 X = FCString::Atoi(*TempStr.Left(StrIdx));
int32 Y = FCString::Atoi(*TempStr.Right(StrIdx));
FIntPoint CustomResolution(X, Y);
Settings->SetScreenResolution(CustomResolution);
Settings->ApplySettings(true);
}
}
}