Gems: Assets paths for gems local to a project are incorrect #8480
Description
Describe the bug
Assets paths for gems local to a project are incorrect
Steps to reproduce
Steps to reproduce the behavior:
- Create an external gem:
scripts\o3de.bat create-gem -gp C:\TestGem
- Add a mesh in the test gem Assets folder, for example TestMesh.fbx
- Enable the gem for your project:
scripts\o3de enable-gem -gp C:\TestGem -pp C:\TestProject
- Put TestMesh in a scene of TestProject and save
- Move
C:\TestGem
folder toC:\TestProject\Gems\TestGem
to make it local to your project - Edit
C:\TestProject\project.json
to remove"TestGem"
fromgem_names
and add"Gems/TestGem"
toexternal_subdirectories
- Delete
C:\TestProject\Cache
folder - Re-open the scene with TestMesh. It failed to load the mesh since the asset path was previously testmesh.azmodel and now it's gems/testgem/assets/testmesh.azmodel
Expected behavior
The Assets
folder of local gems should be automatically added to the AssetProcessor ScanFolders like for gems external to the project.
Actual behavior
The gems assets paths are not the same if the gem is local or external to the project.
This cause issues for assets referenced in the scenes but also make the gem unusable if the code of the gem load assets bundle with it (shaders for example).
This is caused by the file Registry/AssetProcessorPlatformConfig.setreg
in the engine which adds the project root folder at order 0:
"ScanFolder Project/Assets": {
"watch": "@PROJECTROOT@",
"display": "@PROJECTNAME@",
"recursive": 1,
"order": 0
},
It is possible to workaround this by adding a setreg file in the Registry folder of the project which adds the Assets
folder of the gem with an order -1:
{
"Amazon": {
"AssetProcessor": {
"Settings": {
"ScanFolder TestGem Assets": {
"watch": "@PROJECTROOT@/Gems/TestGem/Assets",
"recursive": 1,
"order": -1
}
}
}
}
}
But it would probably be better if this could work without this.
Found in Branch
commit 9e96dcf on development branch
also on commit c1d7294 on main branch