Files
UnrealEngineUWP/Engine/Source/Editor/VREditor/VREditorWidgetComponent.cpp
richard graham 46c53b1c0f Updated VREditorWidgetComponent and VREditorCameraWidgetComponent to use materials that ignore pre-exposure so VR menus have same brightness regardless of scene lighting setup.
Added new materials to VREditorAssetContainer to avoid modifying the default materials used for WidgetComponents

#rb zach.brockway, jason.walter#preflight 62d5c4b3d54af4b9a23b6111  #jira UE-157937

[CL 21152798 by richard graham in ue5-main branch]
2022-07-18 17:11:50 -04:00

60 lines
1.4 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "VREditorWidgetComponent.h"
#include "IVREditorModule.h"
#include "VREditorAssetContainer.h"
#include "VREditorMode.h"
UVREditorWidgetComponent::UVREditorWidgetComponent()
: Super(),
DrawingPolicy(EVREditorWidgetDrawingPolicy::Always),
bIsHovering(false),
bHasEverDrawn(false)
{
bSelectable = false;
SetCastShadow(false);
if (UNLIKELY(IsRunningDedicatedServer()) || HasAnyFlags(RF_ClassDefaultObject)) // @todo vreditor: early out to avoid loading font assets in the cooker on Linux
{
return;
}
if (!IsRunningCommandlet())
{
if (IVREditorModule::IsAvailable())
{
IVREditorModule& VRModule = IVREditorModule::Get();
if (UVREditorMode* VRMode = VRModule.GetVRMode())
{
const UVREditorAssetContainer& VRAssetContainer = VRMode->GetAssetContainer();
{
TranslucentMaterial = VRAssetContainer.WidgetMaterial;
TranslucentMaterial_OneSided = VRAssetContainer.WidgetMaterial;
}
}
}
}
}
bool UVREditorWidgetComponent::ShouldDrawWidget() const
{
if ( DrawingPolicy == EVREditorWidgetDrawingPolicy::Always ||
(DrawingPolicy == EVREditorWidgetDrawingPolicy::Hovering && bIsHovering) ||
!bHasEverDrawn )
{
return Super::ShouldDrawWidget();
}
return false;
}
void UVREditorWidgetComponent::DrawWidgetToRenderTarget(float DeltaTime)
{
bHasEverDrawn = true;
Super::DrawWidgetToRenderTarget(DeltaTime);
}