0
$\begingroup$

Is there a way to add an option to change the World Surface Color and Strength settings via a button?

I already coded out the panel and everything, but maybe it's just based on the specific context, which I currently have: world = context.world Which removes everything from my label that I created. This is confusing me, maybe there is already a question similar out there or here and I haven't found it. I apologize for the repeated question, if that's the case.

Thank you.

import bpy

class Panel(bpy.types.Panel):
    bl_label = "Panel"
    bl_idname = "PT_PANEL"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'UI'
    bl_category = 'Panel'

def draw(self, context):
    layout = self.layout
    
    #world = context.world

    row = layout.row()
    row.label(text="Select a shader")
    row.operator()


def register():
    bpy.utils.register_class(Panel)


def unregister():
    bpy.utils.unregister_class(Panel)


if __name__ == "__main__":
    register()
$\endgroup$
2
  • $\begingroup$ can you add more details as its not so clear what you mean by add an option to change the world surface color $\endgroup$
    – Harry McKenzie
    Commented May 9 at 22:27
  • $\begingroup$ The current world is not available directly with the context, but the current scene. Use context.scene.world $\endgroup$
    – Gorgious
    Commented May 13 at 9:22

1 Answer 1

0
$\begingroup$

The current world is not available directly with the context, but the current scene. Use context.scene.world :

    def draw(self, context):
        layout = self.layout        
        world = context.scene.world
        node = world.node_tree.nodes["Background"]
        layout.prop(node.inputs["Color"], "default_value", text="Color")
        layout.prop(node.inputs["Strength"], "default_value", text="Strength")

enter image description here

$\endgroup$

You must log in to answer this question.

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