Assets: Show asset path in asset browser sidebar

It's useful to know where an asset is stored in, before this there was no way
to tell this. This could probably be displayed nicer in the UI but we're
currently unsure how. But at least the information is there now.
This commit is contained in:
2021-07-09 12:33:38 +02:00
committed by Sybren A. Stüvel
parent 35affaa971
commit add6fa0924

View File

@@ -592,15 +592,26 @@ class ASSETBROWSER_PT_metadata(asset_utils.AssetBrowserPanel, Panel):
def draw(self, context):
layout = self.layout
active_file = context.active_file
active_asset = asset_utils.SpaceAssetInfo.get_active_asset(context)
asset_file_handle = context.asset_file_handle
if not active_file or not active_asset:
if asset_file_handle is None:
layout.label(text="No asset selected", icon='INFO')
return
# If the active file is an ID, use its name directly so renaming is possible from right here.
layout.prop(context.id if context.id is not None else active_file, "name", text="")
asset_library = context.asset_library
asset_lib_path = bpy.types.AssetHandle.get_full_library_path(asset_file_handle, asset_library)
if asset_file_handle.local_id:
# If the active file is an ID, use its name directly so renaming is possible from right here.
layout.prop(asset_file_handle.local_id, "name", text="")
row = layout.row()
row.label(text="Source: Current File")
else:
layout.prop(asset_file_handle, "name", text="")
col = layout.column(align=True) # Just to reduce margin.
col.label(text="Source:")
row = col.row()
row.label(text=asset_lib_path)
class ASSETBROWSER_PT_metadata_preview(asset_utils.AssetMetaDataPanel, Panel):