Search Unity

Change GUID without 'Missing script'

Discussion in 'Editor & General Support' started by xofreshxo, May 13, 2021.

  1. xofreshxo

    xofreshxo

    Joined:
    Apr 12, 2017
    Posts:
    79
    So I went to upgrade a Asset Store package today, and one of the files gave me this warning: "Warning file exists in project, but with different GUID. Will override existing asset which may be undesired."

    I proceeded to import the updated script, however this led the component script to be missing across my entire project. To fix this, I had to revert the changes to the GUID in the .meta file and then the component was fixed across all the game objects.

    Should I be concerned that I am not using the GUID in the latest package? There are no issues at the moment but I worry if there is some reason this could impact future updates to the package. Is there a way to change the GUID mapping between unity and that asset? Changing the GUID in the meta file breaks the link. Open to thoughts and suggestions before I decide to use the modified GUID or try to reimport everything from scratch.
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,689
    You can renumber GUIDs... I believe the TextMeshPRO utility has some code in it to do this for TMPRo itself, since it used to be an asset store asset and is now a package.

    By your use of the word "revert" it sounds like you're a good professional dev properly using source control, so I offer you this other possibly easier way:

    You can also just do it by hand with a good search/replace-in-files tool such as Notepad++, steps like this to renumber a single C# file's GUID to a new GUID:

    - make a new C# file to get a new GUID, copy it out, then delete that new file

    - close Unity

    - ransack ALL files* to search / replace the old GUID with the newly-copied-out GUID above.

    For "all files" you really only need .asset, .unity and .prefab files, but you're welcome to ransack all because those GUIDs are pretty unique.

    Dirty-file-wise, you would expect to see the .meta for the C# file you are changing, plus any files it referenced and nothing else.

    If you object to the semi-hacky nature of this, here's a further discussion and screenshots of the actual process of converting a GUID over on a single prefab:

    https://forum.unity.com/threads/how...d-of-the-same-component.1110689/#post-7146788
     
    Last edited: May 17, 2021