Skip to content

Commit

Permalink
added get_levels()
Browse files Browse the repository at this point in the history
  • Loading branch information
Roberto De Ioris committed Dec 17, 2016
1 parent badad57 commit 7874b1c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Source/UnrealEnginePython/Private/UEPyModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,8 @@ static PyMethodDef ue_PyUObject_methods[] = {
{ "set_view_target", (PyCFunction)py_ue_set_view_target, METH_VARARGS, "" },
{ "get_world_delta_seconds", (PyCFunction)py_ue_get_world_delta_seconds, METH_VARARGS, "" },

{ "get_levels", (PyCFunction)py_ue_get_levels, METH_VARARGS, "" },

{ "add_actor_component", (PyCFunction)py_ue_add_actor_component, METH_VARARGS, "" },
{ "add_actor_root_component", (PyCFunction)py_ue_add_actor_root_component, METH_VARARGS, "" },
{ "get_actor_component_by_type", (PyCFunction)py_ue_get_actor_component_by_type, METH_VARARGS, "" },
Expand Down
20 changes: 20 additions & 0 deletions Source/UnrealEnginePython/Private/UEPyWorld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,23 @@ PyObject *py_ue_get_world_delta_seconds(ue_PyUObject * self, PyObject * args) {

return Py_BuildValue("f", UGameplayStatics::GetWorldDeltaSeconds(world));
}

PyObject *py_ue_get_levels(ue_PyUObject * self, PyObject * args) {

ue_py_check(self);

UWorld *world = ue_get_uworld(self);
if (!world)
return PyErr_Format(PyExc_Exception, "unable to retrieve UWorld from uobject");

PyObject *ret = PyList_New(0);

for (ULevel *level : world->GetLevels() ) {
ue_PyUObject *py_obj = ue_get_python_wrapper(level);
if (!py_obj)
continue;
PyList_Append(ret, (PyObject *)py_obj);

}
return ret;
}
4 changes: 3 additions & 1 deletion Source/UnrealEnginePython/Private/UEPyWorld.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ PyObject *py_ue_get_world(ue_PyUObject *, PyObject *);
PyObject *py_ue_has_world(ue_PyUObject *, PyObject *);

PyObject *py_ue_set_view_target(ue_PyUObject *, PyObject *);
PyObject *py_ue_get_world_delta_seconds(ue_PyUObject *, PyObject *);
PyObject *py_ue_get_world_delta_seconds(ue_PyUObject *, PyObject *);

PyObject *py_ue_get_levels(ue_PyUObject *, PyObject *);

0 comments on commit 7874b1c

Please sign in to comment.