Sun Position: add handler to force some prop updates on scene load

This commit is contained in:
Damien Picard 2023-01-07 23:08:52 +01:00
parent b9079cc426
commit 7a41cf88cf
2 changed files with 10 additions and 2 deletions

View File

@ -16,7 +16,7 @@
bl_info = {
"name": "Sun Position",
"author": "Michael Martin",
"version": (3, 1, 2),
"version": (3, 1, 3),
"blender": (3, 0, 0),
"location": "World > Sun Position",
"description": "Show sun position with objects and/or sky texture",
@ -35,6 +35,7 @@ else:
from . import properties, ui_sun, hdr, translations
import bpy
from bpy.app.handlers import persistent
register_classes, unregister_classes = bpy.utils.register_classes_factory(
@ -44,6 +45,12 @@ register_classes, unregister_classes = bpy.utils.register_classes_factory(
ui_sun.SUNPOS_PT_Location, ui_sun.SUNPOS_PT_Time, hdr.SUNPOS_OT_ShowHdr))
@persistent
def sun_scene_handler(scene):
sun_props = bpy.context.scene.sun_pos_properties
sun_props.show_north = sun_props.show_north
def register():
register_classes()
bpy.types.Scene.sun_pos_properties = (
@ -51,10 +58,12 @@ def register():
name="Sun Position",
description="Sun Position Settings"))
bpy.app.handlers.frame_change_post.append(sun_calc.sun_handler)
bpy.app.handlers.load_post.append(sun_scene_handler)
bpy.app.translations.register(__name__, translations.translations_dict)
def unregister():
bpy.app.translations.unregister(__name__)
bpy.app.handlers.frame_change_post.remove(sun_calc.sun_handler)
bpy.app.handlers.load_post.remove(sun_scene_handler)
del bpy.types.Scene.sun_pos_properties
unregister_classes()

View File

@ -87,4 +87,3 @@ else:
elif _north_handle is not None:
bpy.types.SpaceView3D.draw_handler_remove(_north_handle, 'WINDOW')
_north_handle = None
context.area.tag_redraw()