safer in-editor getworld without the polluting logs
This commit is contained in:
@@ -539,17 +539,20 @@ UWorld* FSGXRTracker::FImpl::GetWorld()
|
||||
}
|
||||
|
||||
/// NOTE
|
||||
/// IsInGameThread() check is to avoid EngineScriptHelpers::CheckIfInEditorAndPIE emitting:
|
||||
/// "You are not on the main thread."
|
||||
/// !(GEditor->PlayWorld || GIsPlayInEditorWorld) check is to avoid
|
||||
/// EngineScriptHelpers::CheckIfInEditorAndPIE emitting:
|
||||
/// The Editor is currently in a play mode.
|
||||
// IsInGameThread() check is to avoid EngineScriptHelpers::CheckIfInEditorAndPIE emitting:
|
||||
// "You are not on the main thread."
|
||||
// !(GEditor->PlayWorld || GIsPlayInEditorWorld) check is to avoid
|
||||
// EngineScriptHelpers::CheckIfInEditorAndPIE emitting:
|
||||
// The Editor is currently in a play mode.
|
||||
if (!IsValid(World) && IsInGameThread() && !(GEditor->PlayWorld || GIsPlayInEditorWorld))
|
||||
{
|
||||
UUnrealEditorSubsystem* UnrealEditorSubsystem{GEditor->GetEditorSubsystem<UUnrealEditorSubsystem>()};
|
||||
if (IsValid(UnrealEditorSubsystem))
|
||||
{
|
||||
World = UnrealEditorSubsystem->GetEditorWorld();
|
||||
/// NOTE
|
||||
// This is exactly UnrealEditorSubsystem->GetEditorWorld() without all the annoying warnings that
|
||||
// pollutes the logs. It's safe since we've already done all the checks.
|
||||
World = GEditor->GetEditorWorldContext(false).World();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user