How can I get TSharedPtr,FSceneViewport?

UGameEngine* GameEngine = Cast(GEngine);

this can get TSharedPtr,FSceneViewport,but the cast was fail.How can I get GameEngine?

I have exactly the same problem, and every attempt I do results in failure.

I know this doesn’t answer your question specifically, but it might help! After quite a lot of hours I managed to create a TSharedPtr without crashing the editor.

if (GEngine->GameViewport && GEngine->GameViewport->GetGameViewportWidget()) { TSharedPtr<FSceneViewport> scene_viewport = MakeShareable( new FSceneViewport( GEngine->GameViewport, GEngine->GameViewport->GetGameViewportWidget() ) ); GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Green, TEXT("SceneViewport Set")); } else { GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Failed Setting SceneViewport")); }

I hope it helps!