Skip to content

Commit

Permalink
Use project GameInstance class by default
Browse files Browse the repository at this point in the history
  • Loading branch information
slonopotamus committed Aug 5, 2024
1 parent c09301c commit 401cd76
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 6 additions & 2 deletions Source/UEST/Private/ScopedGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,9 +398,13 @@ bool FScopedGameInstance::TickUntil(const TFunction<bool()>& Condition, const fl
return Condition();
}

FScopedGame& FScopedGame::WithProjectGameInstance()
FScopedGame::FScopedGame()
{
return WithGameInstance(GetDefault<UGameMapsSettings>()->GameInstanceClass.TryLoadClass<UGameInstance>());
GameInstanceClass = GetDefault<UGameMapsSettings>()->GameInstanceClass.TryLoadClass<UGameInstance>();
if (!GameInstanceClass)
{
GameInstanceClass = UGameInstance::StaticClass();
}
}

FScopedGameInstance FScopedGame::Create() const
Expand Down
6 changes: 3 additions & 3 deletions Source/UEST/Public/ScopedGame.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,12 @@ class FScopedGameInstance : FNoncopyable

class FScopedGame
{
TSubclassOf<UGameInstance> GameInstanceClass = UGameInstance::StaticClass();
TSubclassOf<UGameInstance> GameInstanceClass;
bool bGarbageCollectOnDestroy = true;

public:
FScopedGame();

FScopedGame& WithGameInstance(TSubclassOf<UGameInstance> InGameInstanceClass)
{
GameInstanceClass = MoveTemp(InGameInstanceClass);
Expand All @@ -73,7 +75,5 @@ class FScopedGame
return *this;
}

FScopedGame& WithProjectGameInstance();

FScopedGameInstance Create() const;
};

0 comments on commit 401cd76

Please sign in to comment.