How should I update a script to 2.8 that uses the removed 'scene_update_pre' handler?
There are two thing that need to be updated:


Matrix multiplication is now written using @
bpy.app.handlers.depsgraph_update_pre should be used as handler


Unless I've missed something, this should be all the changes that are necessary.



import bpy
import mathutils

cam = bpy.context.scene.objects['Camera']
obj = bpy.context.scene.objects['Cube']

def drive_shapekey(scene):
    obj_mat = cam.matrix_world.inverted() @ obj.matrix_world

    obj_eul = obj_mat.to_euler('XYZ')
    cam_vec = obj_mat.to_translation().normalized()
    obj_vec = mathutils.Vector((0.0, 1.0, 0.0))
    obj_vec.rotate(obj_eul)
    difference = cam_vec.dot(obj_vec)

    key1 = obj.data.shape_keys.key_blocks["Key 1"]
    key1.value = difference


pre_handlers = bpy.app.handlers.depsgraph_update_pre
[pre_handlers.remove(h) for h in pre_handlers if h.__name__ == "drive_shapekey"]
pre_handlers.append(drive_shapekey)