Check for UStevesGameViewportClientBase on first input change rather than at Initialize, the latter is too early

This commit is contained in:
Steve Streeting 2021-04-09 11:47:14 +01:00
parent eead056575
commit dd23ed77dd
2 changed files with 14 additions and 7 deletions

View File

@ -16,12 +16,6 @@ void UStevesGameSubsystem::Initialize(FSubsystemCollectionBase& Collection)
Super::Initialize(Collection);
CreateInputDetector();
InitTheme();
auto GI = GetGameInstance();
auto VC = Cast<UStevesGameViewportClientBase>(GI->GetGameViewportClient());
if (!VC)
UE_LOG(LogStevesUEHelpers, Warning, TEXT("Your GameViewportClient needs to be set to a subclass of UStevesGameViewportClientBase if you want full functionality!"))
}
void UStevesGameSubsystem::Deinitialize()
@ -59,6 +53,18 @@ void UStevesGameSubsystem::InitTheme()
void UStevesGameSubsystem::OnInputDetectorModeChanged(int PlayerIndex, EInputMode NewMode)
{
// We can't check this during Initialize because it's too early
if (!bCheckedViewportClient)
{
auto GI = GetGameInstance();
auto VC = Cast<UStevesGameViewportClientBase>(GI->GetGameViewportClient());
if (!VC)
UE_LOG(LogStevesUEHelpers, Warning, TEXT("Your GameViewportClient needs to be set to a subclass of UStevesGameViewportClientBase if you want full functionality!"))
bCheckedViewportClient = true;
}
auto GI = GetGameInstance();
auto VC = GI->GetGameViewportClient();
auto SVC = Cast<UStevesGameViewportClientBase>(VC);

View File

@ -94,6 +94,7 @@ protected:
protected:
TSharedPtr<FInputModeDetector> InputDetector;
FFocusSystem FocusSystem;
bool bCheckedViewportClient = false;
UPROPERTY(BlueprintReadWrite)
UUiTheme* DefaultUiTheme;