Is there a way for a panel slider to control both an object's material node and a world node at the same time?

I currently have the slider controlling the mix factor of a material that is assigned to a background plane and would like it to also control the mix factor of the world environment textures.

    obj = bpy.data.objects["Sky_Sunset"]

    mat = obj.active_material
    if not mat:
        layout.label("Create a material")

    nodes = mat.node_tree.nodes

    # Define the specific node
    sky_colour = nodes["SkyMix"]

    layout.prop(sky_colour.inputs["Fac"], "default_value", text="Sky Colour")

Any help would be really appreciated.

EDIT: As I had no responses I went a different direction in that I selected the Mix Node for the World and added a driver to the slider, I then selected the target to be the slider on in my panel.

I'm still interested to know the Python route.

EDIT 2: While the Driver route seems to work, on re-opening of the file the connection breaks.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.