safer in-editor getworld without the polluting logs
This commit is contained in:
@@ -129,17 +129,20 @@ UWorld* USGGloveTracker::FImpl::GetWorld()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// NOTE
|
/// NOTE
|
||||||
/// IsInGameThread() check is to avoid EngineScriptHelpers::CheckIfInEditorAndPIE emitting:
|
// IsInGameThread() check is to avoid EngineScriptHelpers::CheckIfInEditorAndPIE emitting:
|
||||||
/// "You are not on the main thread."
|
// "You are not on the main thread."
|
||||||
/// !(GEditor->PlayWorld || GIsPlayInEditorWorld) check is to avoid
|
// !(GEditor->PlayWorld || GIsPlayInEditorWorld) check is to avoid
|
||||||
/// EngineScriptHelpers::CheckIfInEditorAndPIE emitting:
|
// EngineScriptHelpers::CheckIfInEditorAndPIE emitting:
|
||||||
/// The Editor is currently in a play mode.
|
// The Editor is currently in a play mode.
|
||||||
if (!IsValid(World) && IsInGameThread() && !(GEditor->PlayWorld || GIsPlayInEditorWorld))
|
if (!IsValid(World) && IsInGameThread() && !(GEditor->PlayWorld || GIsPlayInEditorWorld))
|
||||||
{
|
{
|
||||||
UUnrealEditorSubsystem* UnrealEditorSubsystem{GEditor->GetEditorSubsystem<UUnrealEditorSubsystem>()};
|
UUnrealEditorSubsystem* UnrealEditorSubsystem{GEditor->GetEditorSubsystem<UUnrealEditorSubsystem>()};
|
||||||
if (IsValid(UnrealEditorSubsystem))
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -539,17 +539,20 @@ UWorld* FSGXRTracker::FImpl::GetWorld()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// NOTE
|
/// NOTE
|
||||||
/// IsInGameThread() check is to avoid EngineScriptHelpers::CheckIfInEditorAndPIE emitting:
|
// IsInGameThread() check is to avoid EngineScriptHelpers::CheckIfInEditorAndPIE emitting:
|
||||||
/// "You are not on the main thread."
|
// "You are not on the main thread."
|
||||||
/// !(GEditor->PlayWorld || GIsPlayInEditorWorld) check is to avoid
|
// !(GEditor->PlayWorld || GIsPlayInEditorWorld) check is to avoid
|
||||||
/// EngineScriptHelpers::CheckIfInEditorAndPIE emitting:
|
// EngineScriptHelpers::CheckIfInEditorAndPIE emitting:
|
||||||
/// The Editor is currently in a play mode.
|
// The Editor is currently in a play mode.
|
||||||
if (!IsValid(World) && IsInGameThread() && !(GEditor->PlayWorld || GIsPlayInEditorWorld))
|
if (!IsValid(World) && IsInGameThread() && !(GEditor->PlayWorld || GIsPlayInEditorWorld))
|
||||||
{
|
{
|
||||||
UUnrealEditorSubsystem* UnrealEditorSubsystem{GEditor->GetEditorSubsystem<UUnrealEditorSubsystem>()};
|
UUnrealEditorSubsystem* UnrealEditorSubsystem{GEditor->GetEditorSubsystem<UUnrealEditorSubsystem>()};
|
||||||
if (IsValid(UnrealEditorSubsystem))
|
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