Ever find yourself needing to clear out mass amounts of logic? Here’s the solution! A simple addon that adds this button in the logic editor:
Copy-Paste this into Blender’s text editor and run, I’ll release an addon version soon.
import bpy
class RemoveAllLogicPlayer(bpy.types.Operator):
bl_idname='wm.ok_removelogic'
bl_label = 'Clear Logic'
def execute(self, context):
obj = bpy.context.active_object
for i in obj.game.sensors:
bpy.ops.logic.sensor_remove(sensor=i.name, object=obj.name)
for i in obj.game.controllers:
bpy.ops.logic.controller_remove(controller=i.name, object=obj.name)
for i in obj.game.actuators:
bpy.ops.logic.actuator_remove(actuator=i.name, object=obj.name)
return({'FINISHED'})
class LOGIC_MT_logicbricks_clear(bpy.types.Header):
bl_label = "Extra Options"
bl_space_type = "LOGIC_EDITOR"
bl_region_type = "UI"
def draw(self, context):
layout = self.layout
layout.operator("wm.ok_removelogic")
def register():
bpy.utils.register_class(LOGIC_MT_logicbricks_clear)
bpy.utils.register_class(RemoveAllLogicPlayer)
def unregister():
bpy.utils.unregister_class(LOGIC_MT_logicbricks_clear)
bpy.utils.unregister_class(RemoveAllLogicPlayer)
if __name__ == "__main__":
register()