Skip to content

Instantly share code, notes, and snippets.

@kotobukid
Last active September 20, 2024 11:52
Show Gist options
  • Save kotobukid/10ade1be8e1bec06ca24f26ec9c37be6 to your computer and use it in GitHub Desktop.
Save kotobukid/10ade1be8e1bec06ca24f26ec9c37be6 to your computer and use it in GitHub Desktop.
自作のアドオン(これの他の)をBlenderのGUI上から再読み込みさせるアドオン
bpy.ops.script.reload()
を呼ぶのが一番確実だったので、それを呼ぶボタンを配置するだけのものに…
旧コードはサブモジュールの更新まではリロードしない
import bpy
bl_info = {
"name": "AddOn Reload",
"blender": (4, 2, 0),
"category": "Object",
"version": (0, 1),
"author": "Kotobukid",
"description": "Enhance development with addon reload functionality",
}
class OBJECT_OT_ReloadAddon(bpy.types.Operator):
"""reload all addons"""
bl_idname = "object.reload_addon"
bl_label = "Reload Addons"
bl_options = {'REGISTER'}
def execute(self, context):
bpy.ops.script.reload()
self.report({'INFO'}, 'Addons have been reloaded.')
return {'FINISHED'}
class OBJECT_PT_ReloadAddon(bpy.types.Panel):
"""Creates a Panel in the Object mode toolbar"""
bl_label = "Reload Addon"
bl_idname = "OBJECT_PT_reload_addon"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = "Godot"
bl_context = "objectmode" # Display in object mode
def draw(self, context):
layout = self.layout
stats_row = layout.row()
stats_row.operator("object.reload_addon", text="Reload", icon="FILE_REFRESH")
def register():
bpy.utils.register_class(OBJECT_OT_ReloadAddon)
bpy.utils.register_class(OBJECT_PT_ReloadAddon)
def unregister():
bpy.utils.unregister_class(OBJECT_OT_ReloadAddon)
bpy.utils.unregister_class(OBJECT_PT_ReloadAddon)
if __name__ == "__main__":
register()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment