Download

Show scene camera view in SViewport

I’ve looked at some complicated examples in the sources, which I kinda understand, but is there an easy way to show the current scene in an SViewport from the point of view of a camera?

I’ve been trying something like this, but with no success. I guess I don’t understand the pieces and what it takes to bring a reference to the game viewport into the widget. Any hints?



TSharedPtr<SCompoundWidget> widget =

(...)


	+ SGridPanel::Slot( 0, 11 ) .ColumnSpan( 2 ) .VAlign(VAlign_Center)
	
		SAssignNew( ShipEngineDesignViewPort, SViewport)
		.RenderDirectlyToWindow(true)
		.IsEnabled( true )
		//.IsEnabled( FSlateApplication::Get().GetNormalExecutionAttribute() )
		.EnableGammaCorrection( false )	
		.EnableBlending( true )
		.Visibility( EVisibility::SelfHitTestInvisible )
	]

(...)

		TSharedPtr<SViewport> gameViewPort = FSlateApplication::Get().GetGameViewport();
		TSharedPtr< FSceneViewport > sv = MakeShareable( new FSceneViewport( GEngine->GameViewport, gameViewPort ) );
		ShipEngineDesignViewPort->SetViewportInterface( sv.ToSharedRef() );
		FSlateApplication::Get().RegisterGameViewport(ShipEngineDesignViewPort.ToSharedRef());

return widget;