AssetEditor: open assets by path from Python, fix OpenAssetEditorById - #20173
Open
Grimwarrior wants to merge 2 commits into
Open
Grimwarrior wants to merge 2 commits into
Grimwarrior wants to merge 2 commits into
Conversation
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>
nick-l-o3de
reviewed
Oct 4, 2026
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)); |
Contributor
There was a problem hiding this comment.
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.
Contributor
Author
There was a problem hiding this comment.
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.