@@ -1531,46 +1531,58 @@ PyObject *py_unreal_engine_blueprint_add_member_variable(PyObject * self, PyObje
15311531
15321532 PyObject *py_blueprint;
15331533 char *name;
1534- char *in_type ;
1534+ PyObject *py_type ;
15351535 PyObject *py_is_array = nullptr ;
1536- if (!PyArg_ParseTuple (args, " Oss|O:blueprint_add_member_variable" , &py_blueprint, &name, &in_type, &py_is_array))
1536+ char *default_value = nullptr ;
1537+ if (!PyArg_ParseTuple (args, " OsO|Os:blueprint_add_member_variable" , &py_blueprint, &name, &py_type, &py_is_array, &default_value))
15371538 {
1538- return NULL ;
1539+ return nullptr ;
15391540 }
15401541
1541- if (!ue_is_pyuobject (py_blueprint))
1542- {
1543- return PyErr_Format (PyExc_Exception, " argument is not a UObject" );
1544- }
1542+ UBlueprint *bp = ue_py_check_type<UBlueprint>(py_blueprint);
1543+ if (!bp)
1544+ return PyErr_Format (PyExc_Exception, " uobject is not a Blueprint" );
15451545
1546- ue_PyUObject *py_obj = (ue_PyUObject *)py_blueprint;
1547- if (!py_obj->ue_object ->IsA <UBlueprint>())
1548- return PyErr_Format (PyExc_Exception, " uobject is not a UBlueprint" );
1549- UBlueprint *bp = (UBlueprint *)py_obj->ue_object ;
1546+ FEdGraphPinType pin;
15501547
1551- bool is_array = false ;
1552- if (py_is_array && PyObject_IsTrue (py_is_array))
1553- is_array = true ;
1548+ if (PyUnicode_Check (py_type))
1549+ {
1550+ char *in_type = PyUnicode_AsUTF8 (py_type);
1551+
1552+ bool is_array = false ;
1553+ if (py_is_array && PyObject_IsTrue (py_is_array))
1554+ is_array = true ;
15541555#if ENGINE_MINOR_VERSION > 14
1555- FEdGraphPinType pin;
1556- pin.PinCategory = UTF8_TO_TCHAR (in_type);
1556+ pin.PinCategory = UTF8_TO_TCHAR (in_type);
15571557#if ENGINE_MINOR_VERSION >= 17
1558- pin.ContainerType = is_array ? EPinContainerType::Array : EPinContainerType::None;
1558+ pin.ContainerType = is_array ? EPinContainerType::Array : EPinContainerType::None;
15591559#else
1560- pin.bIsArray = is_array;
1560+ pin.bIsArray = is_array;
15611561#endif
15621562#else
1563- FEdGraphPinType pin (UTF8_TO_TCHAR (in_type), FString (" " ), nullptr , is_array, false );
1563+ FEdGraphPinType pin2 (UTF8_TO_TCHAR (in_type), FString (" " ), nullptr , is_array, false );
1564+ pin = pin2;
15641565#endif
1566+ }
1567+ else
1568+ {
1569+ FEdGraphPinType *pinptr = ue_py_check_struct<FEdGraphPinType>(py_type);
1570+ if (!pinptr)
1571+ return PyErr_Format (PyExc_Exception, " argument is not a EdGraphPinType" );
1572+ pin = *pinptr;
1573+ }
1574+
1575+ FString DefaultValue = FString (" " );
15651576
1566- if (FBlueprintEditorUtils::AddMemberVariable (bp, UTF8_TO_TCHAR (name), pin))
1577+ if (default_value)
1578+ DefaultValue = FString (default_value);
1579+
1580+ if (FBlueprintEditorUtils::AddMemberVariable (bp, UTF8_TO_TCHAR (name), pin, DefaultValue))
15671581 {
1568- Py_INCREF (Py_True);
1569- return Py_True;
1582+ Py_RETURN_TRUE;
15701583 }
15711584
1572- Py_INCREF (Py_False);
1573- return Py_False;
1585+ Py_RETURN_FALSE;
15741586}
15751587
15761588PyObject *py_unreal_engine_blueprint_set_variable_visibility (PyObject * self, PyObject * args)
0 commit comments