Skip to content

Commit f693e4c

Browse files
author
Roberto De Ioris
committed
added get_material_static_switch_parameter()
1 parent 7df2823 commit f693e4c

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

Source/UnrealEnginePython/Private/UEPyMaterial.cpp

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,37 @@ PyObject *py_ue_get_material_scalar_parameter(ue_PyUObject *self, PyObject * arg
6464

6565
}
6666

67+
PyObject *py_ue_get_material_static_switch_parameter(ue_PyUObject *self, PyObject * args) {
68+
69+
ue_py_check(self);
70+
71+
char *switchName = nullptr;
72+
if (!PyArg_ParseTuple(args, "s:get_material_static_switch_parameter", &switchName)) {
73+
return NULL;
74+
}
75+
76+
if (!self->ue_object->IsA<UMaterialInstance>()) {
77+
return PyErr_Format(PyExc_Exception, "uobject is not a UMaterialInstance");
78+
}
79+
80+
FName parameterName(UTF8_TO_TCHAR(switchName));
81+
82+
UMaterialInstance *material_instance = (UMaterialInstance *)self->ue_object;
83+
84+
bool value = false;
85+
86+
FGuid guid;
87+
material_instance->GetStaticSwitchParameterValue(parameterName, value, guid);
88+
89+
if (value) {
90+
Py_INCREF(Py_True);
91+
return Py_True;
92+
}
93+
94+
Py_INCREF(Py_False);
95+
return Py_False;
96+
}
97+
6798
PyObject *py_ue_set_material_vector_parameter(ue_PyUObject *self, PyObject * args) {
6899
ue_py_check(self);
69100

@@ -240,7 +271,7 @@ PyObject *py_ue_create_material_instance_dynamic(ue_PyUObject *self, PyObject *
240271
}
241272

242273
UMaterialInstanceConstant *material_instance = (UMaterialInstanceConstant *)py_obj->ue_object;
243-
274+
244275
UMaterialInstanceDynamic *material_dynamic = UMaterialInstanceDynamic::Create(material_instance, self->ue_object);
245276

246277
ue_PyUObject *ret = ue_get_python_wrapper(material_dynamic);

Source/UnrealEnginePython/Private/UEPyMaterial.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ PyObject *py_ue_set_material_texture_parameter(ue_PyUObject *, PyObject *);
1111
PyObject *py_ue_get_material_scalar_parameter(ue_PyUObject *, PyObject *);
1212
PyObject *py_ue_get_material_vector_parameter(ue_PyUObject *, PyObject *);
1313
PyObject *py_ue_get_material_texture_parameter(ue_PyUObject *, PyObject *);
14+
PyObject *py_ue_get_material_static_switch_parameter(ue_PyUObject *, PyObject *);
1415

1516
PyObject *py_ue_create_material_instance_dynamic(ue_PyUObject *, PyObject *);
1617

Source/UnrealEnginePython/Private/UEPyModule.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,7 @@ static PyMethodDef ue_PyUObject_methods[] = {
540540
{ "get_material_scalar_parameter", (PyCFunction)py_ue_get_material_scalar_parameter, METH_VARARGS, "" },
541541
{ "get_material_vector_parameter", (PyCFunction)py_ue_get_material_vector_parameter, METH_VARARGS, "" },
542542
{ "get_material_texture_parameter", (PyCFunction)py_ue_get_material_texture_parameter, METH_VARARGS, "" },
543+
{ "get_material_static_switch_parameter", (PyCFunction)py_ue_get_material_static_switch_parameter, METH_VARARGS, "" },
543544
{ "create_material_instance_dynamic", (PyCFunction)py_ue_create_material_instance_dynamic, METH_VARARGS, "" },
544545
#if WITH_EDITOR
545546
{ "set_material_parent", (PyCFunction)py_ue_set_material_parent, METH_VARARGS, "" },

0 commit comments

Comments
 (0)