I am making a plugin that extends the UGameUserSettings
class.
I am trying to make a function that enables certain settings (like raytracing) using console commands, but the world is not initialized at the point when the function is called, so the editor crashes. Is there any way to NOT use console commands to achieve this?
the function looks like this:
void UJF_GameUserSettings::ApplyAdvancedSettings() {
//Misc
if (GEngine->GetWorld() != nullptr) {
if (bEnableBloom) {
GetWorld()->Exec(GetWorld(), TEXT("r.DefaultFeature.Bloom 1"));
}
else
{
GetWorld()->Exec(GetWorld(), TEXT("r.DefaultFeature.Bloom 0"));
}
if (bMotionBlur) {
GetWorld()->Exec(GetWorld(), TEXT("r.DefaultFeature.MotionBlur 1"));
}
else
{
GetWorld()->Exec(GetWorld(), TEXT("r.DefaultFeature.MotionBlur 0"));
}
//Check for ray tracing
if (bRayTracing && GRHISupportsRayTracing) {
GetWorld()->Exec(GetWorld(), TEXT("r.RayTracing 1"));
}
else {
GetWorld()->Exec(GetWorld(), TEXT("r.RayTracing 0"));
}
if (bRayTracing && ShadowsType == 1 && GRHISupportsRayTracing) {
GetWorld()->Exec(GetWorld(), TEXT("r.RayTracing.Shadows 1"));
}
else {
GetWorld()->Exec(GetWorld(), TEXT("r.RayTracing.Shadows 0"));
}
if (bRayTracing && AmbientOcclusionType == 1 && GRHISupportsRayTracing) {
GetWorld()->Exec(GetWorld(), TEXT("r.RayTracing.AmbientOcclusion 1"));
}
else
{
GetWorld()->Exec(GetWorld(), TEXT("r.RayTracing.AmbientOcclusion 0"));
}
if (bRayTracing && ReflectionsType == 1 && GRHISupportsRayTracing) {
GetWorld()->Exec(GetWorld(), TEXT("r.RayTracing.Reflections 1"));
}
else
{
GetWorld()->Exec(GetWorld(), TEXT("r.RayTracing.Reflections 0"));
}
if (bRayTracing && TranslucencyType == 1 && GRHISupportsRayTracing) {
GetWorld()->Exec(GetWorld(), TEXT("r.RayTracing.Translucency 1"));
}
else
{
GetWorld()->Exec(GetWorld(), TEXT("r.RayTracing.Translucency 0"));
}
switch (GIType)
{
case 0:
GetWorld()->Exec(GetWorld(), TEXT("r.RayTracing.GlobalIllumination 0"));
GetWorld()->Exec(GetWorld(), TEXT("r.SSGI.Quality 0"));
break;
case 2:
if (bRayTracing && GRHISupportsRayTracing) {
GetWorld()->Exec(GetWorld(), TEXT("r.SSGI.Quality 0"));
switch (RTGIType)
{
case 0:
GetWorld()->Exec(GetWorld(), TEXT("r.RayTracing.GlobalIllumination 1"));
GetWorld()->Exec(GetWorld(), TEXT("r.RayTracing.GlobalIllumination.EnableFinalGather 1"));
break;
case 1:
GetWorld()->Exec(GetWorld(), TEXT("r.RayTracing.GlobalIllumination 1"));
GetWorld()->Exec(GetWorld(), TEXT("r.RayTracing.GlobalIllumination.EnableFinalGather 0"));
break;
default:
break;
}
break;
}
else
{
break;
}
case 1:
GetWorld()->Exec(GetWorld(), TEXT("r.RayTracing.GlobalIllumination 0"));
GetWorld()->Exec(GetWorld(), TEXT("r.SSGI.Quality " + UKismetMathLibrary::Clamp(ScreenSpaceGIQuality, 1, 4)));
break;
default:
break;
}
}
}
tldr: Is there any way to NOT use the Exec()
function in this case? If there isnt, how can I use
Exec()before the world is initialized? AKA while
GEngine->GetWorld()returns
nullptr` ?