Sitelet https://github.com/o3de/o3de/pull/20173
Skip to content

AssetEditor: open assets by path from Python, fix OpenAssetEditorById - #20173

Open
Grimwarrior wants to merge 2 commits into
o3de:developmentfrom
Grimwarrior:asset-editor-open-by-path
Open

Grimwarrior wants to merge 2 commits into
o3de:developmentfrom
Grimwarrior:asset-editor-open-by-path

Conversation

@Grimwarrior

Copy link
Copy Markdown
Contributor

OpenAssetEditorById and AssetEditorWidgetRequests::OpenAssetById asked the asset manager for a plain AssetData, a type with no handler, so the Python call logged "No handler was registered for this asset" and never opened anything. They now look the real asset type up through the asset catalog first.

Adds OpenAssetEditorByPath to AssetEditorRequestsBus and OpenAssetByPath to AssetEditorWidgetRequestsBus, reflected to Python next to the existing events. They open a source file the way Open Recent does, by running AssetEditorWidget::OpenAssetFromPath, so scripts and tools can open a .attackset, .weapondata or other editable asset without the Open dialog.

OpenAssetEditorById and AssetEditorWidgetRequests::OpenAssetById asked
the asset manager for a plain AssetData, a type with no handler, so the
Python call logged "No handler was registered for this asset" and never
opened anything. They now look the real asset type up through the asset
catalog first.

Adds OpenAssetEditorByPath to AssetEditorRequestsBus and OpenAssetByPath
to AssetEditorWidgetRequestsBus, reflected to Python next to the existing
events. They open a source file the way Open Recent does, by running
AssetEditorWidget::OpenAssetFromPath, so scripts and tools can open a
.attackset, .weapondata or other editable asset without the Open dialog.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Signed-off-by: Grimwarrior <143121582+Grimwarrior@users.noreply.github.com>
@Grimwarrior
Grimwarrior requested review from a team as code owners October 2, 2026 21:17
Comment on lines +92 to +94
AZ::Data::AssetInfo assetInfo;
AZ::Data::AssetCatalogRequestBus::BroadcastResult(assetInfo, &AZ::Data::AssetCatalogRequestBus::Events::GetAssetInfoById, assetId);
OpenAsset(AZ::Data::AssetManager::Instance().GetAsset(assetId, assetInfo.m_assetType, AZ::Data::AssetLoadBehavior::NoLoad));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be worth doing error checking here. Its possible for GetAssetInfoById to fail (return the 0000-0000-000-0000 path and id and type) if for example, the asset was deleted and the id no longer maps to anything in the catalog, but the ID is still assigned to something from a prior session.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks. OpenAssetById now checks assetInfo.m_assetId.IsValid(). If the id isn't in the catalog, it logs a warning and returns instead of calling GetAsset with a null type

Signed-off-by: Grimwarrior <143121582+Grimwarrior@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants