UI: Asset Shelf (Experimental Feature) #104831

Closed
Julian Eisel wants to merge 399 commits from asset-shelf into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
2 changed files with 32 additions and 1 deletions
Showing only changes of commit c8ea7b0572 - Show all commits

View File

@ -278,12 +278,17 @@ class TEXT_MT_text(Menu):
class TEXT_MT_templates_py(Menu):
bl_label = "Python"
def draw(self, _context):
def draw(self, context):
prefs = context.preferences
use_asset_shelf = prefs.experimental.use_asset_shelf
self.path_menu(
bpy.utils.script_paths(subdir="templates_py"),
"text.open",
props_default={"internal": True},
filter_ext=lambda ext: (ext.lower() == ".py"),
filter_path=lambda path, use_asset_shelf=use_asset_shelf:
(use_asset_shelf or not path.endswith("ui_asset_shelf.py")),
)

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()