Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically re-import assets when the .import file is changed outside the editor. #10264

Closed
pgervais opened this issue Jul 22, 2024 · 3 comments

Comments

@pgervais
Copy link

Describe the project you are working on

Simple platformer game. The project involves multiple people exchanging files over git.

Describe the problem or limitation you are having in your project

This particular workflow is broken:

  • initial state of the project directory for all contributors: a set of gltf files imported with physics off (no collision mesh).
  • contributor A changes the import configuration for a set of gltf file to add collision meshes, and reimports the files. Their local .godot/imported directory now contains an updated version with collision meshes.
  • contributor A pushes the change (including the .import files but excluding .godot/imported) to the common repository
  • contributor B fetches the change. It updates their local copy of the .import files but leaves .godot/imported unchanged.

Unless contributor B manually reimports the assets whose import configuration have been changed, or deletes their .godot/imported directory, the new import options are not taken into account for them.

This example uses collision meshes, but the same problem applies to any import option. We ran into obscure issues when tempo information was failing to appear in an audio stream even though it appeared in the import options.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Make the editor reimport assets when their corresponding .import file is modified by another program (git in that case).

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Disclaimer: I haven't looked at the Godot source code yet. What I'm proposing here might not be that straightforward.

Let's consider files asset.gltf and asset.import in the project directory. They have two corresponding files under .godot/imported/: asset.gltf-.md5 and asset.gltf-.scn.

  • add the md5 of the asset.import file inside asset.gltf-.md5. For example options_md5="deadbeefdeadbeefdeadbeefdeadbeef".
  • reimport the asset when the hash in asset.gltf-.md5 doesn't match the asset.import hash anymore, using the same mechanism that triggers a reimport when the gltf file changes.

If this enhancement will not be used often, can it be worked around with a few lines of script?

I think you could write an editor plugin that would implement the proposed feature. It would require a significant number of lines (~100-200).

Is there a reason why this should be core and not an add-on in the asset library?

I believe this enhancement would benefit every team who works with version control, no matter what their project is. Having to add the same add-on in every project is a likely sign that the feature would probably be better in core.

I am aware of the need for the engine to stay lean. Since there is already an auto-reimport mechanism in place when the assets themselves change, I'm not expecting this change to require a lot of code.

@Calinou
Copy link
Member

Calinou commented Jul 22, 2024

This is already implemented in 4.3.beta: godotengine/godot#84974

Can you test 4.3.beta3 after making a backup of your project?

@pgervais
Copy link
Author

That's great news. Will test asap and report.

@pgervais
Copy link
Author

Tested on a simple scene, works like a charm. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants