ogxd / project-curator

A convenient tool to help cleaning and maintaining Unity Projects 🧹✨
Do What The F*ck You Want To Public License
153 stars 27 forks source link

Database not updated when an asset is renamed #15

Closed rhys-vdw closed 1 year ago

rhys-vdw commented 1 year ago

Firstly, thank you for this amazing project, it has become an important part of our workflow.

Our team has reported that references are not updated when an asset is renamed.

To reproduce:

  1. Open curator window
  2. Select asset A that references asset B
  3. Rename asset B to "C"
  4. Observe that neither B nor C appear in A' references
  5. Select asset C and observe that A no longer appears in its "referencers"

Rebuilding the project fixes this problem.

rhys-vdw commented 1 year ago

This also applies to assets that are moved.

rhys-vdw commented 1 year ago

This is coming up a fair bit in my team, so I'm happy to schedule a fix. Are you open to a PR @ogxd?

ogxd commented 1 year ago

Hi @rhys-vdw ! It is supposed to update when an asset is moved (and renamed I guess) but I'll check the reproduction steps when I have some time :) https://github.com/ogxd/project-curator/blob/5a5eb9a29570b6f59d117945552f5a4d4850c6b5/Editor/AssetProcessor.cs#L65

Yes feel free to make a PR if you think you know where the issue lies!

rhys-vdw commented 1 year ago

Good timing. I just started looking into it. I'll let you know how I go.

rhys-vdw commented 1 year ago

It seems a fundamental issue here is that your AssetInfo class stores a list of paths instead of asset GUIDs. Is there a reason why this is the case?

If AssetInfo stored GUIDs then there would be no need to handle the move case at all, because there is no change to references resulting in a file move.

ogxd commented 1 year ago

Mhhh it has been a while since I wrote this, I don't recall the reasons for using a path instead of the Guid. I'll have a look at it! There are probably many improvements that could be done.

rhys-vdw commented 1 year ago

I'm very close to having finished refactoring it to use GUIDs, so you can check out the diff when it's done.