@@ -219,6 +219,73 @@ PyObject *py_ue_get_material_texture_parameter(ue_PyUObject *self, PyObject * ar
219219 return (PyObject *)ret;
220220}
221221
222+ PyObject *py_ue_create_material_instance_dynamic (ue_PyUObject *self, PyObject * args) {
223+
224+ ue_py_check (self);
225+
226+ PyObject *py_material = nullptr ;
227+
228+ if (!PyArg_ParseTuple (args, " O:create_material_instance_dynamic" , &py_material)) {
229+ return NULL ;
230+ }
231+
232+ if (!ue_is_pyuobject (py_material)) {
233+ return PyErr_Format (PyExc_Exception, " argument is not a UObject" );
234+ }
235+
236+ ue_PyUObject *py_obj = (ue_PyUObject *)py_material;
237+
238+ if (!py_obj->ue_object ->IsA <UMaterialInstanceConstant>()) {
239+ return PyErr_Format (PyExc_Exception, " uobject is not a UMaterialInstanceConstant" );
240+ }
241+
242+ UMaterialInstanceConstant *material_instance = (UMaterialInstanceConstant *)py_obj->ue_object ;
243+
244+ UMaterialInstanceDynamic *material_dynamic = UMaterialInstanceDynamic::Create (material_instance, self->ue_object );
245+
246+ ue_PyUObject *ret = ue_get_python_wrapper (material_dynamic);
247+ if (!ret)
248+ return PyErr_Format (PyExc_Exception, " PyUObject is in invalid state" );
249+ Py_INCREF (ret);
250+ return (PyObject *)ret;
251+
252+ }
253+
254+ PyObject *py_ue_set_material (ue_PyUObject *self, PyObject * args) {
255+
256+ ue_py_check (self);
257+
258+ int index;
259+ PyObject *py_material = nullptr ;
260+
261+ if (!PyArg_ParseTuple (args, " iO:set_material" , &index, &py_material)) {
262+ return NULL ;
263+ }
264+
265+ if (!self->ue_object ->IsA <UPrimitiveComponent>()) {
266+ return PyErr_Format (PyExc_Exception, " uobject is not a UPrimitiveComponent" );
267+ }
268+
269+ UPrimitiveComponent *component = (UPrimitiveComponent *)self->ue_object ;
270+
271+ if (!ue_is_pyuobject (py_material)) {
272+ return PyErr_Format (PyExc_Exception, " argument is not a UObject" );
273+ }
274+
275+ ue_PyUObject *py_obj = (ue_PyUObject *)py_material;
276+
277+ if (!py_obj->ue_object ->IsA <UMaterialInterface>()) {
278+ return PyErr_Format (PyExc_Exception, " uobject is not a UMaterialInterface" );
279+ }
280+
281+ UMaterialInterface *material_interface = (UMaterialInterface *)py_obj->ue_object ;
282+
283+ component->SetMaterial (index, material_interface);
284+
285+ Py_INCREF (Py_None);
286+ return Py_None;
287+ }
288+
222289
223290#if WITH_EDITOR
224291PyObject *py_ue_set_material_parent (ue_PyUObject *self, PyObject * args) {
0 commit comments