06-27-2024 04:27 PM
I am implementing Passthrough with UE5.3.2 and MetaXR Plugin 1.95.0.
Passthrough works fine if I add the OculusXRPassthroughLayerComponent to Pawn in UnrealEditor and change the following parts.
I created the following C++ code to dynamically create a UOculusXRPassthroughLayerComponent.
However, when I create the Component with this, Passthrough does not work properly.
What do I need to make Passthrough work?
UCLASS()
class PASSTHROUGHTEST_API UMyPassthroughComponent : public UOculusXRPassthroughLayerComponent
{
GENERATED_BODY()
public:
UMyPassthroughComponent(const FObjectInitializer& OI) : Super(OI)
{
UOculusXRStereoLayerShapeUserDefined* Subobject = OI.CreateDefaultSubobject<UOculusXRStereoLayerShapeUserDefined>(this, FName("OculusXRStereoLayerShapeUserDefined"));
Shape = Subobject;
MarkPassthroughStyleForUpdate();
}
};
UOculusXRPassthroughLayerComponent* UMetaPluginUtils::AddPassthroughComponent(APawn * Pawn 、 boolbManualAttachment)
{
UMyPassthroughComponent* Comp = Cast<UMyPassthroughComponent>(
Pawn->AddComponentByClass(UPassthroughComponent::StaticClass()、
bManualAttachment, FTransform :: Identity, true )) ;
Comp->bSupportsDepth = 1;
Comp->SetPriority(-1);
return Comp;
}
Solved! Go to Solution.
07-01-2024 04:33 PM
I noticed that TickComponent (also BeginPlay) of UMyPassthroughComponent is not working.
I followed the following URL and executed AActor::AddComponentByClass() followed by AActor::FinishAddComponent(),
By doing so, I was able to get TickComponent and Passthrough to work.
https://forums.unrealengine.com/t/add-component-to-actor-in-c-the-final-word/646838/10
07-01-2024 04:33 PM
I noticed that TickComponent (also BeginPlay) of UMyPassthroughComponent is not working.
I followed the following URL and executed AActor::AddComponentByClass() followed by AActor::FinishAddComponent(),
By doing so, I was able to get TickComponent and Passthrough to work.
https://forums.unrealengine.com/t/add-component-to-actor-in-c-the-final-word/646838/10