UI: Asset Shelf (Experimental Feature) #104831
|
@ -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")),
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -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()
|
Loading…
Reference in New Issue