0
$\begingroup$

I have defined a custom Enum property for the Material type:

bpy.types.Material.EMaterial = EnumProperty(
    items=[('none', 'None', ''), ('vertex_lit', 'Vertex Lit', ''), ('transparent', 'Transparent', ''), ('transparent_bfcall', 'Transparent Back Face Cull', '')], name="Material"
)

This’s how I display panel for each material of a selected object:

    def get_materials(self, object):
        slots = object.material_slots
        materials = []
        for slot in slots:
            if slot.material != None:
                materials.append(slot.material)
        return materials

    def draw_material(self, material):
        layout = self.layout
        column = layout.column()
        column.prop(material, 'EMaterial')

    def draw_materials(self, context):
        object = context.active_object
        materials = self.get_materials(object)
        for material in materials:
            self.draw_material(material)

    @classmethod
    def poll(cls, context):
        return context.object != None

    def draw(self, context):
        self.draw_materials(context)

enter image description here I want the name of the property (marked red in the image ) to be dynamic. i.e. it should depend on the material name itself. For example if the name of the material is material_1 the name of the property should be material_1. Is it possible to achieve it?

P.S. please let me know if my question isn’t clear enough , I’ll elaborate it.

$\endgroup$
2

1 Answer 1

2
$\begingroup$

This can be done by adding the optional text argument to column.prop(material, 'EMaterial').

column.prop(material, 'EMaterial', text=material.name)

enter image description here

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .