Skip to content

Commit 7850dd4

Browse files
author
Roberto De Ioris
committed
added get_editor_world_counterpart_actor()
1 parent 6952125 commit 7850dd4

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

Source/UnrealEnginePython/Private/UEPyActor.cpp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,4 +634,25 @@ PyObject *py_ue_get_overlapping_actors(ue_PyUObject * self, PyObject * args) {
634634
}
635635
}
636636
return py_overlapping_actors;
637-
}
637+
}
638+
639+
#if WITH_EDITOR
640+
PyObject *py_ue_get_editor_world_counterpart_actor(ue_PyUObject * self, PyObject * args) {
641+
642+
ue_py_check(self);
643+
644+
AActor *actor = ue_get_actor(self);
645+
if (!actor)
646+
return PyErr_Format(PyExc_Exception, "cannot retrieve actor from UObject");
647+
648+
AActor *editor_actor = EditorUtilities::GetEditorWorldCounterpartActor(actor);
649+
if (!editor_actor)
650+
return PyErr_Format(PyExc_Exception, "unable to retrieve editor counterpart actor");
651+
652+
PyObject *ret = (PyObject *)ue_get_python_wrapper(editor_actor);
653+
if (!ret)
654+
return PyErr_Format(PyExc_Exception, "uobject is in invalid state");
655+
Py_INCREF(ret);
656+
return ret;
657+
}
658+
#endif

Source/UnrealEnginePython/Private/UEPyActor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ PyObject *py_ue_get_actor_velocity(ue_PyUObject *, PyObject *);
1515
PyObject *py_ue_get_actor_label(ue_PyUObject *, PyObject *);
1616
PyObject *py_ue_set_actor_label(ue_PyUObject *, PyObject *);
1717
PyObject *py_ue_find_actor_by_label(ue_PyUObject *, PyObject *);
18+
PyObject *py_ue_get_editor_world_counterpart_actor(ue_PyUObject *, PyObject *);
1819
#endif
1920
PyObject *py_ue_get_owner(ue_PyUObject *, PyObject *);
2021
PyObject *py_ue_add_actor_component(ue_PyUObject *, PyObject *);

Source/UnrealEnginePython/Private/UEPyModule.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,8 @@ static PyMethodDef ue_PyUObject_methods[] = {
384384
{ "get_actor_label", (PyCFunction)py_ue_get_actor_label, METH_VARARGS, "" },
385385
{ "set_actor_label", (PyCFunction)py_ue_set_actor_label, METH_VARARGS, "" },
386386

387+
{ "get_editor_world_counterpart_actor", (PyCFunction)py_ue_get_editor_world_counterpart_actor, METH_VARARGS, "" },
388+
387389
{ "find_actor_by_label", (PyCFunction)py_ue_find_actor_by_label, METH_VARARGS, "" },
388390
{ "save_package", (PyCFunction)py_ue_save_package, METH_VARARGS, "" },
389391
{ "asset_can_reimport", (PyCFunction)py_ue_asset_can_reimport, METH_VARARGS, "" },

0 commit comments

Comments
 (0)