Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Changing GUID for meshes

Discussion in 'Editor & General Support' started by masterahuck, Jul 17, 2023.

  1. masterahuck

    masterahuck

    Joined:
    Sep 10, 2015
    Posts:
    69
    Hello
    How can I change the GUID of my FBX mesh without breaking the link to its prefab?
     
  2. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    5,769
    The GUID is the reference, so changing the GUID breaks the reference. If you would need to write some editor code that swaps out references.
     
  3. KillDashNine

    KillDashNine

    Joined:
    Apr 19, 2020
    Posts:
    449
    Your prefab has references to your model file and these references are guids. Why would you want to swap the guid of your existing model? Unity assigns these guids and they identify your file.

    Your prefab is a text file. You can manually or programmatically swap the prefab to point to another model if you like. First backup, obviously (this stuff can explode). Then search-replace the new guid (from the old mesh and new mesh .meta files) to your prefab, for example:

    sed -i 's/oldguid/newguid/g' myprefab.prefab


    Then click Refresh on all those files to have it reflected in Editor.
     
  4. masterahuck

    masterahuck

    Joined:
    Sep 10, 2015
    Posts:
    69
    Thanks alot, I finally just used a tool to re-generate a GUID and exported the mesh to the new project.
     
    KillDashNine likes this.