Skip to content

Commit 2bb8727

Browse files
author
Roberto De Ioris
committed
added allow_actor_script_execution_in_editor()
1 parent 2906f6a commit 2bb8727

File tree

4 files changed

+26
-3
lines changed

4 files changed

+26
-3
lines changed

Source/UnrealEnginePython/Private/UEPyEditor.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,26 @@ PyObject *py_unreal_engine_get_editor_world(PyObject * self, PyObject * args) {
3333
return (PyObject *)ret;
3434
}
3535

36+
PyObject *py_unreal_engine_allow_actor_script_execution_in_editor(PyObject * self, PyObject * args) {
37+
38+
if (!GEditor)
39+
return PyErr_Format(PyExc_Exception, "no GEditor found");
40+
41+
PyObject *obj = nullptr;
42+
if (!PyArg_ParseTuple(args, "O:allow_actor_script_execution_in_editor", &obj)) {
43+
return NULL;
44+
}
45+
46+
bool enable = false;
47+
if (PyObject_IsTrue(obj))
48+
enable = true;
49+
50+
GAllowActorScriptExecutionInEditor = enable;
51+
52+
Py_INCREF(Py_None);
53+
return Py_None;
54+
}
55+
3656

3757
PyObject *py_unreal_engine_editor_get_selected_actors(PyObject * self, PyObject * args) {
3858

Source/UnrealEnginePython/Private/UEPyEditor.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ PyObject *py_unreal_engine_blueprint_add_ubergraph_page(PyObject *, PyObject *);
6565
// efeng additional functions
6666
PyObject *py_unreal_engine_create_material_instance(PyObject *, PyObject *);
6767

68+
PyObject *py_unreal_engine_allow_actor_script_execution_in_editor(PyObject *, PyObject *);
69+
6870
PyObject *py_unreal_engine_get_asset_referencers(PyObject *, PyObject *);
6971
PyObject *py_unreal_engine_get_asset_dependencies(PyObject *, PyObject *);
7072

Source/UnrealEnginePython/Private/UEPyModule.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ static PyMethodDef unreal_engine_methods[] = {
142142
{ "get_content_dir", py_unreal_engine_get_content_dir, METH_VARARGS, "" },
143143
{ "convert_relative_path_to_full", py_unreal_engine_convert_relative_path_to_full, METH_VARARGS, "" },
144144
#if WITH_EDITOR
145+
{ "allow_actor_script_execution_in_editor", py_unreal_engine_allow_actor_script_execution_in_editor , METH_VARARGS, "" },
145146
{ "get_editor_world", py_unreal_engine_get_editor_world, METH_VARARGS, "" },
146147
{ "editor_get_selected_actors", py_unreal_engine_editor_get_selected_actors, METH_VARARGS, "" },
147148
{ "editor_select_actor", py_unreal_engine_editor_select_actor, METH_VARARGS, "" },
@@ -586,8 +587,8 @@ void ue_pydelegates_cleanup(ue_PyUObject *self) {
586587
UE_LOG(LogPython, Warning, TEXT("Removing UPythonDelegate %p from ue_PyUObject %p mapped to UObject %p"), py_delegate, self, self->ue_object);
587588
#endif
588589
py_delegate->RemoveFromRoot();
589-
}
590590
}
591+
}
591592
self->python_delegates_gc->clear();
592593
delete self->python_delegates_gc;
593594
self->python_delegates_gc = nullptr;
@@ -1262,7 +1263,7 @@ void unreal_engine_py_log_error() {
12621263
}
12631264

12641265
PyErr_Clear();
1265-
}
1266+
}
12661267

12671268
// retrieve a UWorld from a generic UObject (if possible)
12681269
UWorld *ue_get_uworld(ue_PyUObject *py_obj) {

Source/UnrealEnginePython/Private/UEPyObject.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ PyObject *py_ue_broadcast(ue_PyUObject *self, PyObject *args) {
461461

462462
UProperty *u_property = self->ue_object->GetClass()->FindPropertyByName(FName(UTF8_TO_TCHAR(property_name)));
463463
if (!u_property)
464-
return PyErr_Format(PyExc_Exception, "unable to find event property %s", TCHAR_TO_UTF8(property_name));
464+
return PyErr_Format(PyExc_Exception, "unable to find event property %s", property_name);
465465

466466
if (auto casted_prop = Cast<UMulticastDelegateProperty>(u_property)) {
467467
FMulticastScriptDelegate multiscript_delegate = casted_prop->GetPropertyValue_InContainer(self->ue_object);

0 commit comments

Comments
 (0)