Skip to content

Gems: Assets paths for gems local to a project are incorrect #8480

Closed
@ValPKFX

Description

Describe the bug
Assets paths for gems local to a project are incorrect

Steps to reproduce
Steps to reproduce the behavior:

  1. Create an external gem: scripts\o3de.bat create-gem -gp C:\TestGem
  2. Add a mesh in the test gem Assets folder, for example TestMesh.fbx
  3. Enable the gem for your project: scripts\o3de enable-gem -gp C:\TestGem -pp C:\TestProject
  4. Put TestMesh in a scene of TestProject and save
  5. Move C:\TestGem folder to C:\TestProject\Gems\TestGem to make it local to your project
  6. Edit C:\TestProject\project.json to remove "TestGem" from gem_names and add "Gems/TestGem" to external_subdirectories
  7. Delete C:\TestProject\Cache folder
  8. 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

Metadata

Assignees

Labels

kind/bugCategorizes issue or PR as related to a bug.priority/criticalCritical priority. Must be actively worked on as someone's top priority right now.sig/coreCategorizes an issue or PR as relevant to SIG Core

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions