Skip to content

Commit 7965e29

Browse files
author
Roberto De Ioris
committed
added sync_browser_to_assets()
1 parent e04cad5 commit 7965e29

3 files changed

Lines changed: 56 additions & 0 deletions

File tree

‎Source/UnrealEnginePython/Private/UEPyEditor.cpp‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2270,5 +2270,57 @@ PyObject *py_unreal_engine_all_viewport_clients(PyObject * self, PyObject * args
22702270
}
22712271
return py_list;
22722272
}
2273+
2274+
PyObject *py_unreal_engine_editor_sync_browser_to_assets(PyObject * self, PyObject * args)
2275+
{
2276+
PyObject *py_items;
2277+
PyObject *py_focus = nullptr;
2278+
2279+
if (!PyArg_ParseTuple(args, "O|O:sync_browser_to_assets", &py_items, &py_focus))
2280+
return nullptr;
2281+
2282+
PyObject *py_iter = PyObject_GetIter(py_items);
2283+
if (!py_iter)
2284+
{
2285+
return PyErr_Format(PyExc_Exception, "argument is not an iterable of UObject or FAssetData");
2286+
}
2287+
2288+
FContentBrowserModule& ContentBrowserModule = FModuleManager::Get().LoadModuleChecked<FContentBrowserModule>("ContentBrowser");
2289+
2290+
TArray<FAssetData> asset_data;
2291+
TArray<UObject *> uobjects;
2292+
2293+
while (PyObject *py_item = PyIter_Next(py_iter))
2294+
{
2295+
ue_PyFAssetData *py_data = py_ue_is_fassetdata(py_item);
2296+
if (py_data)
2297+
{
2298+
asset_data.Add(py_data->asset_data);
2299+
}
2300+
else
2301+
{
2302+
UObject *u_object = ue_py_check_type<UObject>(py_item);
2303+
if (!u_object)
2304+
{
2305+
return PyErr_Format(PyExc_Exception, "invalid item in iterable, must be UObject or FAssetData");
2306+
}
2307+
uobjects.Add(u_object);
2308+
}
2309+
}
2310+
2311+
if (asset_data.Num() > 0)
2312+
{
2313+
ContentBrowserModule.Get().SyncBrowserToAssets(asset_data, false, py_focus && PyObject_IsTrue(py_focus));
2314+
}
2315+
2316+
if (uobjects.Num() > 0)
2317+
{
2318+
ContentBrowserModule.Get().SyncBrowserToAssets(uobjects, false, py_focus && PyObject_IsTrue(py_focus));
2319+
}
2320+
2321+
Py_DECREF(py_iter);
2322+
2323+
Py_RETURN_NONE;
2324+
}
22732325
#endif
22742326

‎Source/UnrealEnginePython/Private/UEPyEditor.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ PyObject *py_unreal_engine_transactions(PyObject *, PyObject *);
106106

107107
PyObject *py_unreal_engine_all_viewport_clients(PyObject *, PyObject *);
108108

109+
PyObject *py_unreal_engine_editor_sync_browser_to_assets(PyObject *, PyObject *);
110+
109111
PyObject *py_unreal_engine_heightmap_expand(PyObject *, PyObject *);
110112
PyObject *py_unreal_engine_heightmap_import(PyObject *, PyObject *);
111113

‎Source/UnrealEnginePython/Private/UEPyModule.cpp‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@ static PyMethodDef unreal_engine_methods[] = {
234234
{ "get_selected_assets", py_unreal_engine_get_selected_assets, METH_VARARGS, "" },
235235
{ "get_assets_by_class", py_unreal_engine_get_assets_by_class, METH_VARARGS, "" },
236236

237+
{ "sync_browser_to_assets", py_unreal_engine_editor_sync_browser_to_assets, METH_VARARGS, "" },
238+
237239
{ "get_asset_referencers", py_unreal_engine_get_asset_referencers, METH_VARARGS, "" },
238240
{ "get_asset_dependencies", py_unreal_engine_get_asset_dependencies, METH_VARARGS, "" },
239241

0 commit comments

Comments
 (0)