@@ -29,11 +29,14 @@ for a queue of UMovieSceneCapture objects
2929struct FInEditorMultiCapture : TSharedFromThis<FInEditorMultiCapture>
3030{
3131
32- static TWeakPtr<FInEditorMultiCapture> CreateInEditorMultiCapture (TArray<UMovieSceneCapture*> InCaptureObjects)
32+ static TWeakPtr<FInEditorMultiCapture> CreateInEditorMultiCapture (TArray<UMovieSceneCapture*> InCaptureObjects, PyObject *py_callable )
3333 {
3434 // FInEditorCapture owns itself, so should only be kept alive by itself, or a pinned (=> temporary) weakptr
3535 FInEditorMultiCapture* Capture = new FInEditorMultiCapture;
3636 Capture->CaptureObjects = InCaptureObjects;
37+ Capture->py_callable = py_callable;
38+ if (Capture->py_callable )
39+ Py_INCREF (Capture->py_callable );
3740 for (UMovieSceneCapture *SceneCapture : Capture->CaptureObjects )
3841 {
3942 SceneCapture->AddToRoot ();
@@ -55,6 +58,10 @@ struct FInEditorMultiCapture : TSharedFromThis<FInEditorMultiCapture>
5558 SceneCapture->RemoveFromRoot ();
5659 }
5760 OnlyStrongReference = nullptr ;
61+ {
62+ FScopePythonGIL gil;
63+ Py_XDECREF (py_callable);
64+ }
5865 }
5966
6067 void Dequeue ()
@@ -124,6 +131,22 @@ struct FInEditorMultiCapture : TSharedFromThis<FInEditorMultiCapture>
124131
125132 bool PlaySession (float DeltaTime)
126133 {
134+
135+
136+ if (py_callable)
137+ {
138+ GEditor->RequestEndPlayMap ();
139+ FScopePythonGIL gil;
140+ ue_PyUObject *py_capture = ue_get_python_uobject (CurrentCaptureObject);
141+ PyObject *py_ret = PyObject_CallFunction (py_callable, " O" , py_capture);
142+ if (!py_ret)
143+ {
144+ unreal_engine_py_log_error ();
145+ }
146+ Py_XDECREF (py_ret);
147+ }
148+
149+
127150 GEditor->RequestPlaySession (true , nullptr , false );
128151 return false ;
129152 }
@@ -276,6 +299,7 @@ struct FInEditorMultiCapture : TSharedFromThis<FInEditorMultiCapture>
276299 {
277300
278301 FEditorDelegates::EndPIE.RemoveAll (this );
302+
279303 // remove item from the TArray;
280304 CaptureObjects.RemoveAt (0 );
281305
@@ -309,13 +333,16 @@ struct FInEditorMultiCapture : TSharedFromThis<FInEditorMultiCapture>
309333
310334 TSubclassOf<AGameModeBase> CachedGameMode;
311335 TArray<UMovieSceneCapture*> CaptureObjects;
336+
337+ PyObject *py_callable;
312338};
313339
314340PyObject *py_unreal_engine_in_editor_capture (PyObject * self, PyObject * args)
315341{
316342 PyObject *py_scene_captures;
343+ PyObject *py_callable = nullptr ;
317344
318- if (!PyArg_ParseTuple (args, " O:in_editor_capture" , &py_scene_captures))
345+ if (!PyArg_ParseTuple (args, " O|O :in_editor_capture" , &py_scene_captures, &py_callable ))
319346 {
320347 return nullptr ;
321348 }
@@ -348,7 +375,7 @@ PyObject *py_unreal_engine_in_editor_capture(PyObject * self, PyObject * args)
348375 }
349376
350377 Py_BEGIN_ALLOW_THREADS
351- FInEditorMultiCapture::CreateInEditorMultiCapture (Captures);
378+ FInEditorMultiCapture::CreateInEditorMultiCapture (Captures, py_callable );
352379 Py_END_ALLOW_THREADS
353380
354381 Py_RETURN_NONE;
0 commit comments