3535#include " UObject/UEPyAnimSequence.h"
3636#include " UObject/UEPyCapture.h"
3737#include " UObject/UEPyLandscape.h"
38+ #include " UObject/UEPyUserDefinedStruct.h"
3839
3940
4041#include " UEPyAssetUserData.h"
@@ -258,6 +259,7 @@ static PyMethodDef unreal_engine_methods[] = {
258259
259260 { " string_to_guid" , py_unreal_engine_string_to_guid, METH_VARARGS, " " },
260261 { " new_guid" , py_unreal_engine_new_guid, METH_VARARGS, " " },
262+ { " guid_to_string" , py_unreal_engine_guid_to_string, METH_VARARGS, " " },
261263
262264 { " heightmap_expand" , py_unreal_engine_heightmap_expand, METH_VARARGS, " " },
263265 { " heightmap_import" , py_unreal_engine_heightmap_import, METH_VARARGS, " " },
@@ -521,6 +523,12 @@ static PyMethodDef ue_PyUObject_methods[] = {
521523 { " node_reconstruct" , (PyCFunction)py_ue_node_reconstruct, METH_VARARGS, " " },
522524
523525 { " get_material_graph" , (PyCFunction)py_ue_get_material_graph, METH_VARARGS, " " },
526+
527+ { " struct_add_variable" , (PyCFunction)py_ue_struct_add_variable, METH_VARARGS, " " },
528+ { " struct_get_variables" , (PyCFunction)py_ue_struct_get_variables, METH_VARARGS, " " },
529+ { " struct_remove_variable" , (PyCFunction)py_ue_struct_remove_variable, METH_VARARGS, " " },
530+ { " struct_move_variable_up" , (PyCFunction)py_ue_struct_move_variable_up, METH_VARARGS, " " },
531+ { " struct_move_variable_down" , (PyCFunction)py_ue_struct_move_variable_down, METH_VARARGS, " " },
524532#endif
525533
526534 { " is_rooted" , (PyCFunction)py_ue_is_rooted, METH_VARARGS, " " },
@@ -935,7 +943,7 @@ void ue_pydelegates_cleanup(ue_PyUObject *self)
935943 UE_LOG (LogPython, Warning, TEXT (" Removing UPythonDelegate %p from ue_PyUObject %p mapped to UObject %p" ), py_delegate, self, self->ue_object );
936944#endif
937945 py_delegate->RemoveFromRoot ();
938- }
946+ }
939947}
940948 self->python_delegates_gc ->clear ();
941949 delete self->python_delegates_gc ;
@@ -1032,9 +1040,9 @@ static PyObject *ue_PyUObject_getattro(ue_PyUObject *self, PyObject *attr_name)
10321040#else
10331041 return PyLong_FromLong (u_enum->FindEnumIndex (item.Key ));
10341042#endif
1043+ }
10351044 }
10361045 }
1037- }
10381046#endif
10391047 if (self->ue_object ->IsA <UEnum>())
10401048 {
@@ -1046,16 +1054,16 @@ static PyObject *ue_PyUObject_getattro(ue_PyUObject *self, PyObject *attr_name)
10461054 return PyLong_FromLong (u_enum->FindEnumIndex (FName (UTF8_TO_TCHAR (attr))));
10471055#endif
10481056 }
1049- }
1057+ }
10501058
10511059 if (function)
10521060 {
10531061 // swallow previous exception
10541062 PyErr_Clear ();
10551063 return py_ue_new_callable (function, self->ue_object );
10561064 }
1065+ }
10571066 }
1058- }
10591067 return ret;
10601068}
10611069
@@ -2048,7 +2056,7 @@ void unreal_engine_py_log_error()
20482056 if (zero)
20492057 {
20502058 msg = PyBytes_AsString (zero);
2051- }
2059+ }
20522060#else
20532061 msg = PyString_AsString (PyObject_Str (value));
20542062#endif
@@ -2234,8 +2242,7 @@ PyObject *ue_py_convert_property(UProperty *prop, uint8 *buffer)
22342242 Py_INCREF (ret);
22352243 return (PyObject *)ret;
22362244 }
2237- Py_INCREF (Py_None);
2238- return Py_None;
2245+ Py_RETURN_NONE;
22392246 }
22402247
22412248 if (auto casted_prop = Cast<UClassProperty>(prop))
@@ -2753,24 +2760,47 @@ bool ue_py_convert_pyobject(PyObject *py_obj, UProperty *prop, uint8 *buffer)
27532760 ue_PyUObject *ue_obj = (ue_PyUObject *)py_obj;
27542761 if (ue_obj->ue_object ->IsA <UClass>())
27552762 {
2756- auto casted_prop = Cast<UClassProperty>(prop);
2757- if (!casted_prop)
2758- return false ;
2759- casted_prop->SetPropertyValue_InContainer (buffer, (UClass *)ue_obj->ue_object );
2760- return true ;
2763+ if (auto casted_prop = Cast<UClassProperty>(prop))
2764+ {
2765+ casted_prop->SetPropertyValue_InContainer (buffer, ue_obj->ue_object );
2766+ return true ;
2767+ }
2768+ else if (auto casted_prop = Cast<USoftClassProperty>(prop))
2769+ {
2770+ casted_prop->SetPropertyValue_InContainer (buffer, FSoftObjectPtr (ue_obj->ue_object ));
2771+ return true ;
2772+ }
2773+ else if (auto casted_prop = Cast<USoftObjectProperty>(prop))
2774+ {
2775+ casted_prop->SetPropertyValue_InContainer (buffer, FSoftObjectPtr (ue_obj->ue_object ));
2776+ return true ;
2777+ }
2778+
2779+ return false ;
27612780 }
27622781
2782+
27632783 if (ue_obj->ue_object ->IsA <UObject>())
27642784 {
2765- auto casted_prop = Cast<UObjectPropertyBase>(prop);
2766- if (!casted_prop)
2767- return false ;
2768- // ensure the object type is correct, otherwise crash could happen (soon or later)
2769- if (!ue_obj->ue_object ->IsA (casted_prop->PropertyClass ))
2770- return false ;
2771- casted_prop->SetObjectPropertyValue_InContainer (buffer, ue_obj->ue_object );
2772- return true ;
2785+ if (auto casted_prop = Cast<UObjectPropertyBase>(prop))
2786+ {
2787+ // ensure the object type is correct, otherwise crash could happen (soon or later)
2788+ if (!ue_obj->ue_object ->IsA (casted_prop->PropertyClass ))
2789+ return false ;
2790+ casted_prop->SetObjectPropertyValue_InContainer (buffer, ue_obj->ue_object );
2791+ return true ;
2792+ }
2793+ else if (auto casted_prop = Cast<USoftObjectProperty>(prop))
2794+
2795+ {
2796+ if (!ue_obj->ue_object ->IsA (casted_prop->PropertyClass ))
2797+ return false ;
2798+ casted_prop->SetPropertyValue_InContainer (buffer, FSoftObjectPtr (ue_obj->ue_object ));
2799+ return true ;
2800+ }
2801+
27732802 }
2803+ return false ;
27742804 }
27752805
27762806 if (py_obj == Py_None)
@@ -2978,9 +3008,9 @@ PyObject *py_ue_ufunction_call(UFunction *u_function, UObject *u_obj, PyObject *
29783008#else
29793009 prop->ImportText (*default_key_value, prop->ContainerPtrToValuePtr <uint8>(buffer), PPF_Localized, NULL );
29803010#endif
2981- }
3011+ }
29823012#endif
2983- }
3013+ }
29843014
29853015 Py_ssize_t tuple_len = PyTuple_Size (args);
29863016
@@ -3463,3 +3493,19 @@ UFunction *unreal_engine_add_function(UClass *u_class, char *name, PyObject *py_
34633493
34643494 return function;
34653495}
3496+
3497+ FGuid *ue_py_check_fguid (PyObject *py_obj)
3498+ {
3499+ ue_PyUScriptStruct *ue_py_struct = py_ue_is_uscriptstruct (py_obj);
3500+ if (!ue_py_struct)
3501+ {
3502+ return nullptr ;
3503+ }
3504+
3505+ if (ue_py_struct->u_struct == FindObject<UScriptStruct>(ANY_PACKAGE, UTF8_TO_TCHAR ((char *)" Guid" )))
3506+ {
3507+ return (FGuid*)ue_py_struct->data ;
3508+ }
3509+
3510+ return nullptr ;
3511+ }
0 commit comments