From 22e7aa72b7187a42bfe334ab0f356049a4fe09c9 Mon Sep 17 00:00:00 2001 From: drewcassidy Date: Tue, 24 Dec 2019 20:03:34 -0800 Subject: [PATCH] Fix texture preview in Workbench --- op_texture_preview.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/op_texture_preview.py b/op_texture_preview.py index f7d5b15..24f429b 100644 --- a/op_texture_preview.py +++ b/op_texture_preview.py @@ -65,6 +65,7 @@ def preview_texture(self, context): break if image: + material = utilities_bake.get_image_material(image) for obj in objects: print("Map {}".format(obj.name)) @@ -78,8 +79,7 @@ def preview_texture(self, context): # Create material with image bpy.ops.object.material_slot_add() - obj.material_slots[0].material = utilities_bake.get_image_material( - image) + obj.material_slots[0].material = material obj.display_type = 'TEXTURED' # Re-Select objects @@ -91,7 +91,11 @@ def preview_texture(self, context): # Change View mode to TEXTURED for space in view_area.spaces: if space.type == 'VIEW_3D': - space.shading.type = 'MATERIAL' + if bpy.context.scene.render.engine == 'BLENDER_WORKBENCH': + space.shading.type = 'SOLID' + space.shading.color_type = 'TEXTURE' + else: + space.shading.type = 'MATERIAL' # Enter local view # bpy.ops.view3d.localview({'area': view_area})