Hi, I’ve been trying to load a GLTF model during runtime (using the plugin) into a scene and then render via MRQ.
To streamline this I am trying an approach by Commandlet, giving the glb URL through as an Argument.
Since the Plugin can only load during runtime however, I have been trying to execute the Level Blueprint during PIE. Unfortunately I have not been successful to execute a PIE via commandlet yet however.
#include "VideoExportCommandlet.h"
#include "Engine/World.h"
#include "GM_ComLetMode.h"
#include "UnrealEd.h"
#include "Editor.h"
#include "Engine/World.h"
#include "Tests/AutomationCommon.h"
#include "Misc/AutomationTest.h"
#include "Async/TaskGraphInterfaces.h"
int32 UVideoExportCommandlet::Main(const FString& Params)
{
UWorld* World = GEditor->GetEditorWorldContext().World();
if(!World)
{
UE_LOG(LogTemp, Error, TEXT("Failed to get editor world context."));
return -1;
}
FEditorFileUtils::LoadMap("/Game/Maps/Main", false, true);
// Ensure the world is properly loaded
if (!World->PersistentLevel)
{
UE_LOG(LogTemp, Error, TEXT("World PersistentLevel is not valid after loading map:"));
return -1;
}
// Setup the PIE parameters
FRequestPlaySessionParams PlaySessionParams;
PlaySessionParams.EditorPlaySettings = GetMutableDefault<ULevelEditorPlaySettings>();
// Start Play In Editor (PIE) session
GEditor->RequestPlaySession(PlaySessionParams);
while(!GEditor->IsPlayingSessionInEditor())
{
FTaskGraphInterface::Get().ProcessThreadUntilIdle(ENamedThreads::GameThread);
FPlatformProcess::Sleep(0.1f);
}
}
It is forever stuck in the IsPlayingSessionInEditor() loop. Using IsPlayInProgress() instead seems to go through, however neither a GameMode nor a WorldContext Object can be found after.
ThePlaySessionParams look as follows using MutuableDefault:
