From 015b169b9b017f5af58c54c6398f31cdbbf8f1b8 Mon Sep 17 00:00:00 2001 From: sup39 Date: Tue, 1 Feb 2022 20:29:10 +0900 Subject: [PATCH] Support blender 2.93 --- BlenderCOL.py | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/BlenderCOL.py b/BlenderCOL.py index 580d9d5..c090618 100644 --- a/BlenderCOL.py +++ b/BlenderCOL.py @@ -1,13 +1,15 @@ +isReload = "bl_info" in locals() bl_info = { - "name": "Export COL for Super Mario Sunshine", - "author": "Blank", - "version": (1, 0, 0), - "blender": (2, 71, 0), + "name": "Import/Export COL for Super Mario Sunshine", + "author": "Blank (modified by sup39)", + "version": (1, 0, 1), + "blender": (2, 93, 0), "location": "File > Export > Collision (.col)", "description": "This script allows you do export col files directly from blender. Based on Blank's obj2col", "warning": "Runs update function every 0.2 seconds", "category": "Import-Export" } + import random import bpy import bmesh @@ -194,10 +196,9 @@ class ImportCOL(Operator, ExportHelper): #Operator that exports the collision mo mesh = bpy.data.meshes.new("mesh") # add a new mesh obj = bpy.data.objects.new("CollisionObj", mesh) # add a new object using the mesh - scene = bpy.context.scene - scene.objects.link(obj) # put the object into the scene (link) - scene.objects.active = obj # set as the active object in the scene - obj.select = True # select object + bpy.context.scene.collection.objects.link(obj) # put the object into the scene (link) + bpy.context.view_layer.objects.active = obj # set as the active object in the scene + obj.select_set(True) # select object mesh = obj.data bm = bmesh.new() @@ -352,8 +353,8 @@ def register(): for i in classes: register_class(i) bpy.types.Material.ColEditor = PointerProperty(type=CollisionProperties) #store in the scene - bpy.types.INFO_MT_file_export.append(menu_export) #Add to export menu - bpy.types.INFO_MT_file_import.append(menu_import) #Add to import menu + bpy.types.TOPBAR_MT_file_export.append(menu_export) #Add to export menu + bpy.types.TOPBAR_MT_file_import.append(menu_import) #Add to import menu def menu_export(self, context): @@ -365,12 +366,20 @@ def menu_import(self, context): def unregister(): for i in classes: unregister_class(i) - bpy.types.INFO_MT_file_export.remove(menu_export) - bpy.types.INFO_MT_file_import.remove(menu_import) - - + bpy.types.TOPBAR_MT_file_export.remove(menu_export) + bpy.types.TOPBAR_MT_file_import.remove(menu_import) # This allows you to run the script directly from blenders text editor # to test the addon without having to install it. if __name__ == "__main__": - register() \ No newline at end of file + register() +else: # on add-on enabled + # try unregister first + if isReload: + try: + unregister() + except Exception: + import traceback + traceback.print_exc() + # call register to add option to menu + register()