Skip to content

Commit 7c4344f

Browse files
author
Roberto De Ioris
committed
added play_preview_sound
1 parent ee3642a commit 7c4344f

3 files changed

Lines changed: 24 additions & 2 deletions

File tree

‎Source/UnrealEnginePython/Private/UEPyEditor.cpp‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2175,5 +2175,23 @@ PyObject *py_unreal_engine_heightmap_import(PyObject * self, PyObject * args)
21752175
return Py_BuildValue((char *)"Oii", PyByteArray_FromStringAndSize((char *)imported.Data.GetData(), imported.Data.Num() * sizeof(uint16)), resolution.Width, resolution.Height);
21762176
}
21772177

2178+
PyObject *py_unreal_engine_play_preview_sound(PyObject * self, PyObject * args)
2179+
{
2180+
if (!GEditor)
2181+
return PyErr_Format(PyExc_Exception, "no GEditor found");
2182+
2183+
PyObject *py_sound;
2184+
if (!PyArg_ParseTuple(args, "O:play_preview_sound", &py_sound))
2185+
return nullptr;
2186+
2187+
USoundBase *sound = ue_py_check_type<USoundBase>(py_sound);
2188+
if (!sound)
2189+
return PyErr_Format(PyExc_Exception, "argument is not a USoundBase");
2190+
2191+
GEditor->PlayPreviewSound(sound);
2192+
2193+
Py_RETURN_NONE;
2194+
}
2195+
21782196
#endif
21792197

‎Source/UnrealEnginePython/Private/UEPyEditor.h‎

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

107107
PyObject *py_unreal_engine_heightmap_expand(PyObject *, PyObject *);
108108
PyObject *py_unreal_engine_heightmap_import(PyObject *, PyObject *);
109+
110+
PyObject *py_unreal_engine_play_preview_sound(PyObject *, PyObject *);
109111
#endif

‎Source/UnrealEnginePython/Private/UEPyModule.cpp‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,12 @@ static PyMethodDef unreal_engine_methods[] = {
254254

255255
{ "string_to_guid", py_unreal_engine_string_to_guid, METH_VARARGS, "" },
256256
{ "new_guid", py_unreal_engine_new_guid, METH_VARARGS, "" },
257-
#if WITH_EDITOR
257+
258258
{ "heightmap_expand", py_unreal_engine_heightmap_expand, METH_VARARGS, "" },
259259
{ "heightmap_import", py_unreal_engine_heightmap_import, METH_VARARGS, "" },
260-
#endif
260+
261+
{ "play_preview_sound", py_unreal_engine_play_preview_sound, METH_VARARGS, "" },
262+
261263
#pragma warning(suppress: 4191)
262264
{ "get_assets_by_filter", (PyCFunction)py_unreal_engine_get_assets_by_filter, METH_VARARGS | METH_KEYWORDS, "" },
263265
{ "create_blueprint", py_unreal_engine_create_blueprint, METH_VARARGS, "" },

0 commit comments

Comments
 (0)