Files
UnrealEngineUWP/Engine/Plugins/Experimental/VirtualCamera/Source/VCamExtensions/Private/VCamBaseActorWithPreset.cpp
Dominik Peacock d62b5497cd Make VCamActor work for cooking on all platforms by inheriting from new base actor
#jira UE-184889
#jira UE-184890
#jira UE-185531
#rb none
#preflight https://horde.devtools.epicgames.com/job/645b7add6534a4f50496b4e3
#fyi Jason.Walter

[CL 25401997 by Dominik Peacock in ue5-main branch]
2023-05-10 07:23:34 -04:00

58 lines
1.9 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "VCamBaseActorWithPreset.h"
#include "VCamComponent.h"
#include "BuiltinProviders/VCamPixelStreamingSession.h"
#include "Interfaces/IPluginManager.h"
#include "Output/VCamOutputRemoteSession.h"
namespace UE::VCamExtensions::Private
{
static bool IsPixelStreamingEnabledPlatform()
{
// Instead of #if directives look up the .uplugin file once so this code automatically updates when support changes
static bool bCache = []()
{
IPluginManager& PluginManager = IPluginManager::Get();
if (const TSharedPtr<IPlugin> Plugin = PluginManager.FindPlugin(TEXT("VirtualCameraCore")))
{
const FModuleDescriptor* PixelStreamingModule = Plugin->GetDescriptor().Modules.FindByPredicate([](const FModuleDescriptor& Module)
{
return Module.Name.IsEqual(TEXT("PixelStreamingVCam"));
});
return PixelStreamingModule && PixelStreamingModule->IsLoadedInCurrentConfiguration();
}
return false;
}();
return bCache;
}
}
void AVCamBaseActorWithPreset::PostActorCreated()
{
Super::PostActorCreated();
// Do not do this for actors drag and dropped into the level editor
if (HasAnyFlags(RF_Transient))
{
return;
}
// We expect the child Blueprint to create the output providers
TArray<UVCamOutputProviderBase*> PixelStreamingSessions;
TArray<UVCamOutputProviderBase*> RemoteSessions;
GetVCamComponent()->GetOutputProvidersByClass(UVCamPixelStreamingSession::StaticClass(), PixelStreamingSessions);
GetVCamComponent()->GetOutputProvidersByClass(UVCamOutputRemoteSession::StaticClass(), RemoteSessions);
const bool bEnablePixelStreaming = UE::VCamExtensions::Private::IsPixelStreamingEnabledPlatform();
for (UVCamOutputProviderBase* PixelStreamer : PixelStreamingSessions)
{
PixelStreamer->SetActive(bEnablePixelStreaming);
}
for (UVCamOutputProviderBase* RemoteSession : RemoteSessions)
{
RemoteSession->SetActive(!bEnablePixelStreaming);
}
}