@@ -1867,30 +1867,26 @@ PyObject *py_unreal_engine_add_level_to_world(PyObject *self, PyObject * args)
18671867 return NULL ;
18681868 }
18691869
1870- if (!ue_is_pyuobject (py_world))
1871- return PyErr_Format (PyExc_Exception, " argument is not a UWorld" );
1872-
1873- ue_PyUObject *py_obj_world = (ue_PyUObject *)py_world;
1874-
1875- if (!py_obj_world->ue_object ->IsA <UWorld>())
1870+ UWorld *u_world = ue_py_check_type<UWorld>(py_world);
1871+ if (!u_world)
18761872 {
18771873 return PyErr_Format (PyExc_Exception, " argument is not a UWorld" );
18781874 }
18791875
1880- UWorld *u_world = (UWorld *)py_obj_world->ue_object ;
1881-
18821876 UClass *streaming_mode_class = ULevelStreamingKismet::StaticClass ();
18831877 if (py_bool && PyObject_IsTrue (py_bool))
18841878 {
18851879 streaming_mode_class = ULevelStreamingAlwaysLoaded::StaticClass ();
18861880 }
18871881
18881882 ULevel *level = (ULevel *)EditorLevelUtils::AddLevelToWorld (u_world, UTF8_TO_TCHAR (name), streaming_mode_class);
1889- if (level)
1883+ if (! level)
18901884 {
1891- // TODO: update levels list
1885+ return PyErr_Format (PyExc_Exception, " unable to add \" %s \" to the world " , name);
18921886 }
18931887
1888+ FEditorDelegates::RefreshLevelBrowser.Broadcast ();
1889+
18941890 ue_PyUObject *ret = ue_get_python_wrapper (level);
18951891 if (!ret)
18961892 return PyErr_Format (PyExc_Exception, " uobject is in invalid state" );
@@ -1908,22 +1904,41 @@ PyObject *py_unreal_engine_move_selected_actors_to_level(PyObject *self, PyObjec
19081904 return NULL ;
19091905 }
19101906
1911- if (!ue_is_pyuobject (py_level))
1912- return PyErr_Format (PyExc_Exception, " argument is not a ULevelStreaming" );
1907+ ULevel *level = ue_py_check_type<ULevel>(py_level);
1908+ if (!level)
1909+ return PyErr_Format (PyExc_Exception, " argument is not a ULevel" );
19131910
1914- ue_PyUObject *py_obj_level = (ue_PyUObject *)py_level ;
1911+ GEditor-> MoveSelectedActorsToLevel (level) ;
19151912
1916- if (!py_obj_level->ue_object ->IsA <ULevel>())
1913+ Py_RETURN_NONE;
1914+ }
1915+
1916+ PyObject *py_unreal_engine_move_actor_to_level (PyObject *self, PyObject * args)
1917+ {
1918+ PyObject *py_actor;
1919+ PyObject *py_level;
1920+ if (!PyArg_ParseTuple (args, " OO:move_actor_to_level" , &py_actor, &py_level))
19171921 {
1918- return PyErr_Format (PyExc_Exception, " argument is not a ULevelStreaming " ) ;
1922+ return NULL ;
19191923 }
19201924
1921- ULevel *level = (ULevel *)py_obj_level->ue_object ;
1925+ AActor *actor = ue_py_check_type<AActor>(py_actor);
1926+ if (!actor)
1927+ return PyErr_Format (PyExc_Exception, " argument is not an Actor" );
19221928
1923- GEditor->MoveSelectedActorsToLevel (level);
1929+ ULevel *level = ue_py_check_type<ULevel>(py_level);
1930+ if (!level)
1931+ return PyErr_Format (PyExc_Exception, " argument is not a ULevel" );
19241932
1925- Py_INCREF (Py_None);
1926- return Py_None;
1933+ TArray<AActor *> actors;
1934+ actors.Add (actor);
1935+
1936+ if (UEditorLevelUtils::MoveActorsToLevel (actors, level) != 1 )
1937+ {
1938+ return PyErr_Format (PyExc_Exception, " unable to move actor to level" );
1939+ }
1940+
1941+ Py_RETURN_NONE;
19271942}
19281943
19291944PyObject *py_unreal_engine_editor_take_high_res_screen_shots (PyObject * self, PyObject * args)
0 commit comments