// Copyright Epic Games, Inc. All Rights Reserved. #include "LyraPlayerCameraManager.h" #include "Containers/UnrealString.h" #include "Engine/Canvas.h" #include "Engine/Engine.h" #include "GameFramework/Pawn.h" #include "GameFramework/PlayerController.h" #include "HAL/Platform.h" #include "LyraCameraComponent.h" #include "LyraUICameraManagerComponent.h" #include "Math/Color.h" #include "Misc/AssertionMacros.h" #include "UObject/NameTypes.h" #include "UObject/ObjectPtr.h" #include "UObject/UObjectBaseUtility.h" class FDebugDisplayInfo; static FName UICameraComponentName(TEXT("UICamera")); ALyraPlayerCameraManager::ALyraPlayerCameraManager(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) { DefaultFOV = LYRA_CAMERA_DEFAULT_FOV; ViewPitchMin = LYRA_CAMERA_DEFAULT_PITCH_MIN; ViewPitchMax = LYRA_CAMERA_DEFAULT_PITCH_MAX; UICamera = CreateDefaultSubobject(UICameraComponentName); } ULyraUICameraManagerComponent* ALyraPlayerCameraManager::GetUICameraComponent() const { return UICamera; } void ALyraPlayerCameraManager::UpdateViewTarget(FTViewTarget& OutVT, float DeltaTime) { // If the UI Camera is looking at something, let it have priority. if (UICamera->NeedsToUpdateViewTarget()) { Super::UpdateViewTarget(OutVT, DeltaTime); UICamera->UpdateViewTarget(OutVT, DeltaTime); return; } Super::UpdateViewTarget(OutVT, DeltaTime); } void ALyraPlayerCameraManager::DisplayDebug(UCanvas* Canvas, const FDebugDisplayInfo& DebugDisplay, float& YL, float& YPos) { check(Canvas); FDisplayDebugManager& DisplayDebugManager = Canvas->DisplayDebugManager; DisplayDebugManager.SetFont(GEngine->GetSmallFont()); DisplayDebugManager.SetDrawColor(FColor::Yellow); DisplayDebugManager.DrawString(FString::Printf(TEXT("LyraPlayerCameraManager: %s"), *GetNameSafe(this))); Super::DisplayDebug(Canvas, DebugDisplay, YL, YPos); const APawn* Pawn = (PCOwner ? PCOwner->GetPawn() : nullptr); if (const ULyraCameraComponent* CameraComponent = ULyraCameraComponent::FindCameraComponent(Pawn)) { CameraComponent->DrawDebug(Canvas); } }