Skip to content

Commit

Permalink
added sync_browser_to_assets()
Browse files Browse the repository at this point in the history
  • Loading branch information
Roberto De Ioris committed Dec 15, 2017
1 parent e04cad5 commit 7965e29
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
52 changes: 52 additions & 0 deletions Source/UnrealEnginePython/Private/UEPyEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2270,5 +2270,57 @@ PyObject *py_unreal_engine_all_viewport_clients(PyObject * self, PyObject * args
}
return py_list;
}

PyObject *py_unreal_engine_editor_sync_browser_to_assets(PyObject * self, PyObject * args)
{
PyObject *py_items;
PyObject *py_focus = nullptr;

if (!PyArg_ParseTuple(args, "O|O:sync_browser_to_assets", &py_items, &py_focus))
return nullptr;

PyObject *py_iter = PyObject_GetIter(py_items);
if (!py_iter)
{
return PyErr_Format(PyExc_Exception, "argument is not an iterable of UObject or FAssetData");
}

FContentBrowserModule& ContentBrowserModule = FModuleManager::Get().LoadModuleChecked<FContentBrowserModule>("ContentBrowser");

TArray<FAssetData> asset_data;
TArray<UObject *> uobjects;

while (PyObject *py_item = PyIter_Next(py_iter))
{
ue_PyFAssetData *py_data = py_ue_is_fassetdata(py_item);
if (py_data)
{
asset_data.Add(py_data->asset_data);
}
else
{
UObject *u_object = ue_py_check_type<UObject>(py_item);
if (!u_object)
{
return PyErr_Format(PyExc_Exception, "invalid item in iterable, must be UObject or FAssetData");
}
uobjects.Add(u_object);
}
}

if (asset_data.Num() > 0)
{
ContentBrowserModule.Get().SyncBrowserToAssets(asset_data, false, py_focus && PyObject_IsTrue(py_focus));
}

if (uobjects.Num() > 0)
{
ContentBrowserModule.Get().SyncBrowserToAssets(uobjects, false, py_focus && PyObject_IsTrue(py_focus));
}

Py_DECREF(py_iter);

Py_RETURN_NONE;
}
#endif

2 changes: 2 additions & 0 deletions Source/UnrealEnginePython/Private/UEPyEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ PyObject *py_unreal_engine_transactions(PyObject *, PyObject *);

PyObject *py_unreal_engine_all_viewport_clients(PyObject *, PyObject *);

PyObject *py_unreal_engine_editor_sync_browser_to_assets(PyObject *, PyObject *);

PyObject *py_unreal_engine_heightmap_expand(PyObject *, PyObject *);
PyObject *py_unreal_engine_heightmap_import(PyObject *, PyObject *);

Expand Down
2 changes: 2 additions & 0 deletions Source/UnrealEnginePython/Private/UEPyModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ static PyMethodDef unreal_engine_methods[] = {
{ "get_selected_assets", py_unreal_engine_get_selected_assets, METH_VARARGS, "" },
{ "get_assets_by_class", py_unreal_engine_get_assets_by_class, METH_VARARGS, "" },

{ "sync_browser_to_assets", py_unreal_engine_editor_sync_browser_to_assets, METH_VARARGS, "" },

{ "get_asset_referencers", py_unreal_engine_get_asset_referencers, METH_VARARGS, "" },
{ "get_asset_dependencies", py_unreal_engine_get_asset_dependencies, METH_VARARGS, "" },

Expand Down

0 comments on commit 7965e29

Please sign in to comment.