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

Use GUID metadata instead of hardcoded paths #4270

Closed
AndreSacilotto opened this issue Mar 24, 2022 · 1 comment
Closed

Use GUID metadata instead of hardcoded paths #4270

AndreSacilotto opened this issue Mar 24, 2022 · 1 comment

Comments

@AndreSacilotto
Copy link

AndreSacilotto commented Mar 24, 2022

Describe the project you are working on

I'm like to experiment with various folder organization layouts.

Describe the problem or limitation you are having in your project

Change the folder paths are annoying and paths don't update automatically.
This is a possible solution to #899.

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

Create metadata for every script and resource file. The metadata file will contains a unique id also called GUID.

The engine will use it to find the path to the script when the reference is lost, solving the problem of moving things around.

This totally based in how I think Unity accomplish it.
I don't think it would be too difficult to implement, as metadata already exists in the engine, like images .import files.

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

Currently I think that no script or resource metadata file is generated.
So the first step would be generate it, shouldn't be that hard godot already have a metadata file format the .import. After generating the file we need to create a good GUID generation algoritm, I'm not good at math, but I know the godot team is.

From here you can choose one of several different solutions. So here's some that I have thinked:

Instead of saving the path to a file you would save the GUID of that file. And when entering in play mode the engine would change all GUID to actual file paths. Yes, this would make compile time longer.

The engine would save both the GUID and file path. The GUID would only be used when the script refence is not find, so it would use it to try to find the lost reference.

So how the engine would know the path to a GUID, It's simple we have global "list" that store GUID as Key and the File Path as Value, so whenever a file is created or moved this "list" would need to be updated.

Well it's all very good what would be the catch?

  1. Well moving files would be slower.
  2. The startup time would have a big impact (hello unity). Because it would need to load all metadata files on startup.

Conclusion:

For me it's worth. I know the engine is know to be lightweight, but this feature it's one of the biggest differences between godot and unity(I never used unreal), moving from an file path system to a indentification system would make the engine even simpler for beginners, no more hardcoded paths only PackedScene Exports.

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

It's a breaking change on the engine current behavior

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

I don't think it's possible

@KoBeWi
Copy link
Member

KoBeWi commented Mar 24, 2022

This is already implemented in 4.0: godotengine/godot#50676

@KoBeWi KoBeWi closed this as completed Mar 24, 2022
@Calinou Calinou added requires core feedback Feature needs feedback from core developers topic:core and removed requires core feedback Feature needs feedback from core developers labels Mar 24, 2022
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