[Bf-extensions-cvs] [899c25c9] master: Sun position: T80379 Startup breaks add-on: no World and UI warning
Damien Picard
noreply at git.blender.org
Wed Oct 28 23:19:51 CET 2020
Commit: 899c25c9a5ce128ddd776fc45121b3373ecf1b49
Author: Damien Picard
Date: Wed Oct 28 23:08:51 2020 +0100
Branches: master
https://developer.blender.org/rBA899c25c9a5ce128ddd776fc45121b3373ecf1b49
Sun position: T80379 Startup breaks add-on: no World and UI warning
- Take into account the situation when no World datablock is assigned.
- Also apply this to HDRI texture mode's environment texture
- Add warnings when either no World datablock is assigned or no node
tree is assigned to the World.
===================================================================
M sun_position/ui_sun.py
===================================================================
diff --git a/sun_position/ui_sun.py b/sun_position/ui_sun.py
index fa79a3f0..2eb969d2 100644
--- a/sun_position/ui_sun.py
+++ b/sun_position/ui_sun.py
@@ -99,8 +99,20 @@ class SUNPOS_PT_Panel(bpy.types.Panel):
col = flow.column(align=True)
col.label(text="Environment texture:")
- col.prop_search(sp, "hdr_texture",
- context.scene.world.node_tree, "nodes", text="")
+
+ if context.scene.world is not None:
+ if context.scene.world.node_tree is not None:
+ col.prop_search(sp, "hdr_texture",
+ context.scene.world.node_tree, "nodes")
+ col.prop_search(sp, "sky_texture",
+ context.scene.world.node_tree, "nodes")
+ else:
+ col.label(text="Please activate Use Nodes in the World panel.",
+ icon="ERROR")
+ else:
+ col.label(text="Please select World in the World panel.",
+ icon="ERROR")
+
col.separator()
col = flow.column(align=True)
@@ -122,7 +134,7 @@ class SUNPOS_PT_Panel(bpy.types.Panel):
else:
prop_text="Bind Texture to Sun "
col.prop(sp, "bind_to_sun", toggle=True, icon="CONSTRAINT",
- text=prop_text)
+ text=prop_text)
row = col.row(align=True)
row.enabled = not sp.bind_to_sun
@@ -148,9 +160,16 @@ class SUNPOS_PT_Panel(bpy.types.Panel):
col.prop(sp, "time_spread")
col.separator()
- if context.scene.world.node_tree is not None:
- col.prop_search(sp, "sky_texture", context.scene.world.node_tree,
- "nodes")
+ if context.scene.world is not None:
+ if context.scene.world.node_tree is not None:
+ col.prop_search(sp, "sky_texture",
+ context.scene.world.node_tree, "nodes")
+ else:
+ col.label(text="Please activate Use Nodes in the World panel.",
+ icon="ERROR")
+ else:
+ col.label(text="Please select World in the World panel.",
+ icon="ERROR")
class SUNPOS_PT_Location(bpy.types.Panel):
bl_space_type = "PROPERTIES"
More information about the Bf-extensions-cvs
mailing list