File tree Expand file tree Collapse file tree 3 files changed +15
-11
lines changed
Expand file tree Collapse file tree 3 files changed +15
-11
lines changed Original file line number Diff line number Diff line change 1919 {
2020 "Name": "CheckAppInstance",
2121 "Type": "Runtime",
22- "LoadingPhase": "Default ",
22+ "LoadingPhase": "EarliestPossible ",
2323 "WhitelistPlatforms": [
2424 "Win64"
2525 ]
Original file line number Diff line number Diff line change @@ -11,15 +11,18 @@ UCheckAppInstanceBPLibrary::UCheckAppInstanceBPLibrary(const FObjectInitializer&
1111
1212void UCheckAppInstanceBPLibrary::CheckAnotherAppInstance (bool bIsEnabled)
1313{
14- #if !UE_EDITOR
15- // Only one instance of the game can be initialized!
16- const UGeneralProjectSettings& ProjectSettings = *GetDefault<UGeneralProjectSettings>();
17- const FString LockFilePath = FPlatformProcess::UserTempDir () + ProjectSettings.ProjectID .ToString ();
18- if (!IFileManager::Get ().CreateFileWriter (*LockFilePath, 0 ) && bIsEnabled)
19- {
20- FPlatformApplicationMisc::RequestMinimize ();
21- FPlatformMisc::RequestExit (0 );
22- }
14+ #if !UE_EDITOR
15+ FCoreDelegates::OnAllModuleLoadingPhasesComplete.AddLambda ([bIsEnabled]()
16+ {
17+ // Only one instance of the game can be initialized!
18+ const UGeneralProjectSettings& ProjectSettings = *GetDefault<UGeneralProjectSettings>();
19+ const FString LockFilePath = FPlatformProcess::UserTempDir () + ProjectSettings.ProjectID .ToString ();
20+ if (!IFileManager::Get ().CreateFileWriter (*LockFilePath, 0 ) && bIsEnabled)
21+ {
22+ FPlatformApplicationMisc::RequestMinimize ();
23+ FPlatformMisc::RequestExit (0 );
24+ }
25+ });
2326#endif
2427}
2528
Original file line number Diff line number Diff line change 44
55#include " Kismet/BlueprintFunctionLibrary.h"
66#include " HAL/FileManager.h"
7- #include " Runtime/ApplicationCore/Public/Windows/WindowsPlatformApplicationMisc .h"
7+ #include " HAL/PlatformApplicationMisc .h"
88#include " GeneralProjectSettings.h"
9+ #include " Misc/CoreDelegates.h"
910#include " CheckAppInstanceBPLibrary.generated.h"
1011
1112UCLASS ()
You can’t perform that action at this time.
0 commit comments