Keep remote control responsive in background
This commit is contained in:
parent
148ffec10f
commit
ae97ea79ed
8 changed files with 68 additions and 5 deletions
Binary file not shown.
Binary file not shown.
3
Config/DefaultEditorSettings.ini
Normal file
3
Config/DefaultEditorSettings.ini
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
[/Script/UnrealEd.EditorPerformanceSettings]
|
||||
bThrottleCPUWhenNotForeground=False
|
||||
bAllowSlateThrottling=False
|
||||
|
|
@ -6,6 +6,10 @@ CommonButtonAcceptKeyHandling=TriggerClick
|
|||
CommonUI.CheckKeyboardFocusAndParentage=1
|
||||
CommonUI.DisallowUserFocusedWidgetForPendingFocusRecipient=1
|
||||
CommonUI.FallbackToDesiredOnAutoRestoreFailure=1
|
||||
t.IdleWhenNotForeground=0
|
||||
Slate.bAllowThrottling=0
|
||||
Slate.AllowSlateToSleep=0
|
||||
Slate.ThrottleWhenMouseIsMoving=0
|
||||
|
||||
[/Script/EngineSettings.GeneralProjectSettings]
|
||||
ProjectID=DB73111A464E4036F3BE8CB0373528D9
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ namespace
|
|||
ALedVolumeDisplayActor::ALedVolumeDisplayActor()
|
||||
{
|
||||
PrimaryActorTick.bCanEverTick = true;
|
||||
PrimaryActorTick.bTickEvenWhenPaused = true;
|
||||
|
||||
VoxelInstances = CreateDefaultSubobject<UHierarchicalInstancedStaticMeshComponent>(TEXT("VoxelInstances"));
|
||||
SetRootComponent(VoxelInstances);
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ ALedVolumeRemoteControlActor::ALedVolumeRemoteControlActor()
|
|||
{
|
||||
PrimaryActorTick.bCanEverTick = true;
|
||||
PrimaryActorTick.bStartWithTickEnabled = true;
|
||||
PrimaryActorTick.bTickEvenWhenPaused = true;
|
||||
|
||||
static ConstructorHelpers::FObjectFinder<UMaterialInterface> DefaultLedMaterial(TEXT("/Game/LedVolume/Materials/M_LedVoxelGpu.M_LedVoxelGpu"));
|
||||
if (DefaultLedMaterial.Succeeded())
|
||||
|
|
@ -78,7 +79,7 @@ bool ALedVolumeRemoteControlActor::ShouldTickIfViewportsOnly() const
|
|||
void ALedVolumeRemoteControlActor::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
|
||||
{
|
||||
Super::PostEditChangeProperty(PropertyChangedEvent);
|
||||
QueueApply();
|
||||
ApplyToTarget();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -9,8 +9,10 @@
|
|||
#include "Editor.h"
|
||||
#include "Engine/Engine.h"
|
||||
#include "EngineUtils.h"
|
||||
#include "Editor/EditorPerformanceSettings.h"
|
||||
#include "FileHelpers.h"
|
||||
#include "HAL/PlatformFileManager.h"
|
||||
#include "HAL/IConsoleManager.h"
|
||||
#include "LedVolumeRemoteControlActor.h"
|
||||
#include "Misc/CoreDelegates.h"
|
||||
#include "Misc/PackageName.h"
|
||||
|
|
@ -27,6 +29,10 @@ public:
|
|||
FDefaultGameModuleImpl::StartupModule();
|
||||
#if WITH_EDITOR
|
||||
UE_LOG(LogTemp, Display, TEXT("LED volume module startup: scheduling editor helpers"));
|
||||
ConfigureUnattendedRemoteControl();
|
||||
BackgroundRemoteControlTickerHandle = FTSTicker::GetCoreTicker().AddTicker(
|
||||
FTickerDelegate::CreateRaw(this, &FLedcube3dModule::TickBackgroundRemoteControlSupport),
|
||||
5.0f);
|
||||
if (GEngine)
|
||||
{
|
||||
PostEditorTickHandle = GEngine->OnPostEditorTick().AddRaw(this, &FLedcube3dModule::TickEditorHelpers);
|
||||
|
|
@ -48,6 +54,11 @@ public:
|
|||
FTSTicker::GetCoreTicker().RemoveTicker(RemotePresetTickerHandle);
|
||||
RemotePresetTickerHandle.Reset();
|
||||
}
|
||||
if (BackgroundRemoteControlTickerHandle.IsValid())
|
||||
{
|
||||
FTSTicker::GetCoreTicker().RemoveTicker(BackgroundRemoteControlTickerHandle);
|
||||
BackgroundRemoteControlTickerHandle.Reset();
|
||||
}
|
||||
if (PostEditorTickHandle.IsValid() && GEngine)
|
||||
{
|
||||
GEngine->OnPostEditorTick().Remove(PostEditorTickHandle);
|
||||
|
|
@ -58,6 +69,47 @@ public:
|
|||
}
|
||||
|
||||
#if WITH_EDITOR
|
||||
void ConfigureUnattendedRemoteControl()
|
||||
{
|
||||
if (UEditorPerformanceSettings* PerformanceSettings = GetMutableDefault<UEditorPerformanceSettings>())
|
||||
{
|
||||
bool bSettingsChanged = false;
|
||||
if (PerformanceSettings->bThrottleCPUWhenNotForeground)
|
||||
{
|
||||
PerformanceSettings->bThrottleCPUWhenNotForeground = false;
|
||||
bSettingsChanged = true;
|
||||
}
|
||||
if (PerformanceSettings->bAllowSlateThrottling)
|
||||
{
|
||||
PerformanceSettings->bAllowSlateThrottling = false;
|
||||
bSettingsChanged = true;
|
||||
}
|
||||
if (bSettingsChanged)
|
||||
{
|
||||
PerformanceSettings->SaveConfig();
|
||||
}
|
||||
}
|
||||
|
||||
SetConsoleVariable(TEXT("t.IdleWhenNotForeground"), 0);
|
||||
SetConsoleVariable(TEXT("Slate.bAllowThrottling"), 0);
|
||||
SetConsoleVariable(TEXT("Slate.AllowSlateToSleep"), 0);
|
||||
SetConsoleVariable(TEXT("Slate.ThrottleWhenMouseIsMoving"), 0);
|
||||
}
|
||||
|
||||
bool TickBackgroundRemoteControlSupport(float DeltaSeconds)
|
||||
{
|
||||
ConfigureUnattendedRemoteControl();
|
||||
return true;
|
||||
}
|
||||
|
||||
void SetConsoleVariable(const TCHAR* Name, int32 Value)
|
||||
{
|
||||
if (IConsoleVariable* Variable = IConsoleManager::Get().FindConsoleVariable(Name))
|
||||
{
|
||||
Variable->Set(Value, ECVF_SetByProjectSetting);
|
||||
}
|
||||
}
|
||||
|
||||
void TickEditorHelpers(float DeltaSeconds)
|
||||
{
|
||||
if (bRemotePresetBuilt || RemotePresetBuildAttempts > 60)
|
||||
|
|
@ -342,6 +394,7 @@ public:
|
|||
}
|
||||
|
||||
FTSTicker::FDelegateHandle RemotePresetTickerHandle;
|
||||
FTSTicker::FDelegateHandle BackgroundRemoteControlTickerHandle;
|
||||
FDelegateHandle PostEditorTickHandle;
|
||||
int32 RemotePresetBuildAttempts = 0;
|
||||
bool bRemotePresetBuilt = false;
|
||||
|
|
|
|||
|
|
@ -710,6 +710,7 @@
|
|||
method: 'PUT',
|
||||
body: JSON.stringify({ PropertyValue: value })
|
||||
});
|
||||
await callFunction('ApplyToTarget', { silent: true, refresh: false });
|
||||
setApiState(true, 'connected');
|
||||
} catch (error) {
|
||||
setApiState(false, 'error');
|
||||
|
|
@ -717,16 +718,16 @@
|
|||
}
|
||||
}
|
||||
|
||||
async function callFunction(name) {
|
||||
async function callFunction(name, options = {}) {
|
||||
try {
|
||||
await api(`/remote/preset/${state.presetId}/function/${encodeURIComponent(name)}`, {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify({ Parameters: {} })
|
||||
});
|
||||
showToast(`${name} done`);
|
||||
await refreshValues();
|
||||
if (!options.silent) showToast(`${name} done`);
|
||||
if (options.refresh !== false) await refreshValues();
|
||||
} catch (error) {
|
||||
showToast(`${name}: ${error.message}`, true);
|
||||
if (!options.silent) showToast(`${name}: ${error.message}`, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue