blender/scripts/templates_py/ui_asset_shelf.py
Julian Eisel 728d47f3e4 Asset shelf: Use asset representation for asset shelf BPY methods
Changes the `asset_poll()` and `draw_context_menu()` methods for asset
shelves to use the `AssetRepresentation` type, instead of `AssetHandle`.
The latter should be removed, so it's better to avoid using it in the
asset shelf BPY to avoid future compatibility breakage. This is possible
now with d421ebac5e.
2023-09-15 16:17:44 +02:00

27 lines
490 B
Python

import bpy
class MyAssetShelf(bpy.types.AssetShelf):
bl_space_type = 'VIEW_3D'
bl_idname = "VIEW3D_AST_my_asset_shelf"
@classmethod
def poll(cls, context):
return context.mode == 'OBJECT'
@classmethod
def asset_poll(cls, asset):
return asset.id_type in {'MATERIAL', 'OBJECT'}
def register():
bpy.utils.register_class(MyAssetShelf)
def unregister():
bpy.utils.unregister_class(MyAssetShelf)
if __name__ == "__main__":
register()