Skip to content

Commit c5d5225

Browse files
author
Roberto De Ioris
committed
exposed set_slate_widget for UWidgetComponent
1 parent 74e6f3f commit c5d5225

File tree

4 files changed

+41
-1
lines changed

4 files changed

+41
-1
lines changed

Source/UnrealEnginePython/Private/UEPyModule.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "UEPyAudio.h"
2323
#include "UEPySequencer.h"
2424
#include "UEPyViewport.h"
25+
#include "UEPyWidgetComponent.h"
2526

2627
#include "UEPyPackage.h"
2728
#include "UEPyAssetUserData.h"
@@ -559,6 +560,9 @@ static PyMethodDef ue_PyUObject_methods[] = {
559560
{ "get_world_location_at_distance_along_spline", (PyCFunction)py_ue_get_world_location_at_distance_along_spline, METH_VARARGS, "" },
560561
{ "get_spline_length", (PyCFunction)py_ue_get_spline_length, METH_VARARGS, "" },
561562

563+
// WidgetComponent
564+
{ "set_slate_widget", (PyCFunction)py_ue_set_slate_widget, METH_VARARGS, "" },
565+
562566
{ "get_actor_velocity", (PyCFunction)py_ue_get_actor_velocity, METH_VARARGS, "" },
563567

564568
{ "play_sound_at_location", (PyCFunction)py_ue_play_sound_at_location, METH_VARARGS, "" },
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include "UnrealEnginePythonPrivatePCH.h"
2+
3+
4+
#include "Runtime/UMG/Public/Components/WidgetComponent.h"
5+
6+
7+
PyObject *py_ue_set_slate_widget(ue_PyUObject * self, PyObject * args) {
8+
9+
ue_py_check(self);
10+
11+
PyObject *py_widget;
12+
13+
if (!PyArg_ParseTuple(args, "O", &py_widget)) {
14+
return nullptr;
15+
}
16+
17+
UWidgetComponent *widget_component = ue_py_check_type<UWidgetComponent>(self);
18+
if (!widget_component)
19+
return PyErr_Format(PyExc_Exception, "uobject is not a UWidgetComponent");
20+
21+
ue_PySWidget *s_widget = py_ue_is_swidget(py_widget);
22+
if (!s_widget)
23+
return PyErr_Format(PyExc_Exception, "argument is not a SWidget");
24+
25+
widget_component->SetSlateWidget(s_widget->s_widget);
26+
27+
Py_RETURN_NONE;
28+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#pragma once
2+
3+
4+
#include "UnrealEnginePython.h"
5+
6+
7+
PyObject *py_ue_set_slate_widget(ue_PyUObject *, PyObject *);

Source/UnrealEnginePython/UnrealEnginePython.Build.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ public UnrealEnginePython(TargetInfo Target)
110110
"SlateCore",
111111
"MovieScene",
112112
"LevelSequence",
113-
"HTTP"
113+
"HTTP",
114+
"UMG"
114115
// ... add private dependencies that you statically link with here ...
115116
}
116117
);

0 commit comments

Comments
 (0)