I accidentally moved some of my sprites and now I can't remember where they were originally. Now in Unity, it says missign - sprite. So can't I get the location saved in scene file??? i.e. if it is referring to Desktop\file.extension and I move it to Desktop\files\file.extension, can I get Desktop\file.extension in Editor???


Unity uses GUID (globally unique identifiers) to keep track of asset references. Any reference to an asset in your project will refer to it by its GUID under the hood.

When you create or move/copy in a new asset file, Unity generates a new GUID for it, and stores it in a ".meta" file alongside it, along with any relevant import settings for the asset.

So for instance if your sprite image is "[project path]\Assets\Sprites\mySprite.png", then its GUID will be stored in "[project path]\Assets\Sprites\mySprite.png.meta"

These files are hidden by default, but you can configure the editor to save "visible meta files" and use asset serialization mode "force text" to inspect these GUID and their references by hand.

When you move or rename files in the project window in Unity itself, it automatically moves/renames the corresponding meta files too, to keep everything in sync. No other files need to be updated to reflect the new name/location, because they only refer to the GUID, which hasn't changed.

But if you move an asset using your OS file explorer, then to Unity it looks like you deleted the file from its original place (so it deletes the now-unused meta file that had the GUID recorded in it), and then you created a new file in a new location (so Unity creates a new .meta file with a new GUID for this brand new asset). Since the file has a new GUID now, existing references to that sprite are broken.

If you catch this early, before Unity has deleted the .meta files, you can go inspect the .meta files that were left behind and move them to the folder where their corresponding data files went, so your data files keep their old GUIDs.

If Unity has already deleted these files, then you may be out of luck. You can try going through your recycle bin to see if the old .meta files are there for you to undelete. Failing that, you might have to go fix each reference by hand. If you have a lot of references to just a few files, you can peek into the scene or prefab file to find the old GUID and paste it into the file's new .meta file to repair all references to that one file at once. But if each asset is referenced just once or twice, doing it by hand through the editor interface might be simpler.

So, moral of the story:

  • Move/rename files inside Unity itself, not in external tools.

  • OR, if you have to move/rename something elsewhere, be sure to move/rename the .meta files at the same time.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.