UI: Add asset shelf Python UI template

Adds a new "Ui Asset Shelf" template to the script editor, demonstrating
how scripts can register own asset shelves. The asset shelf is designed
as a new standard UI element that add-ons, application templates and the
like can use, so this is useful. It's also useful as a quick way to test
and customize the asset shelf.

The script is only available in the UI if the "Asset Shelf" experimental
feature is enabled in the Preferences.
This commit is contained in:
Julian Eisel
2023-08-03 17:16:10 +02:00
parent 94fdafe906
commit 6764e69491
2 changed files with 33 additions and 1 deletions

View File

@@ -0,0 +1,26 @@
import bpy
class MyAssetShelf(bpy.types.AssetShelf):
bl_space_type = 'VIEW_3D'
bl_idname = "my_template.my_material_asset_shelf"
@classmethod
def poll(cls, context):
return bool(context.object and context.object.mode == 'OBJECT')
@classmethod
def asset_poll(cls, asset):
return asset.file_data.id_type in {'MATERIAL', 'OBJECT'}
def register():
bpy.utils.register_class(MyAssetShelf)
def unregister():
bpy.utils.unregister_class(MyAssetShelf)
if __name__ == "__main__":
register()