Skip to content

Commit e1965f8

Browse files
author
Roberto De Ioris
committed
added support for UInterfaceProperty, fixes 20tab#366
1 parent b44186f commit e1965f8

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

Source/UnrealEnginePython/Private/UEPyModule.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2393,14 +2393,20 @@ bool ue_py_convert_pyobject(PyObject *py_obj, UProperty *prop, uint8 *buffer, in
23932393
return true;
23942394
}
23952395
else if (auto casted_prop_soft_object = Cast<USoftObjectProperty>(prop))
2396-
23972396
{
23982397
if (!ue_obj->ue_object->IsA(casted_prop_soft_object->PropertyClass))
23992398
return false;
24002399
casted_prop_soft_object->SetPropertyValue_InContainer(buffer, FSoftObjectPtr(ue_obj->ue_object), index);
24012400
return true;
24022401
}
2403-
2402+
else if (auto casted_prop_interface = Cast<UInterfaceProperty>(prop))
2403+
{
2404+
// ensure the object type is correct, otherwise crash could happen (soon or later)
2405+
if (!ue_obj->ue_object->GetClass()->ImplementsInterface(casted_prop_interface->InterfaceClass))
2406+
return false;
2407+
casted_prop_interface->SetPropertyValue_InContainer(buffer, FScriptInterface(ue_obj->ue_object), index);
2408+
return true;
2409+
}
24042410
}
24052411
return false;
24062412
}
@@ -2622,8 +2628,8 @@ PyObject *py_ue_ufunction_call(UFunction *u_function, UObject *u_obj, PyObject *
26222628
#endif
26232629
}
26242630
#endif
2625-
}
26262631
}
2632+
}
26272633

26282634

26292635
Py_ssize_t tuple_len = PyTuple_Size(args);
@@ -2735,7 +2741,7 @@ PyObject *py_ue_ufunction_call(UFunction *u_function, UObject *u_obj, PyObject *
27352741

27362742
Py_INCREF(Py_None);
27372743
return Py_None;
2738-
}
2744+
}
27392745

27402746
PyObject *ue_bind_pyevent(ue_PyUObject *u_obj, FString event_name, PyObject *py_callable, bool fail_on_wrong_property)
27412747
{
@@ -3102,7 +3108,7 @@ UFunction *unreal_engine_add_function(UClass *u_class, char *name, PyObject *py_
31023108
#endif
31033109

31043110
return function;
3105-
}
3111+
}
31063112

31073113
FGuid *ue_py_check_fguid(PyObject *py_obj)
31083114
{

0 commit comments

Comments
 (0)