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 How the fileId of Model files generated.

Discussion in 'Editor & General Support' started by Blastom1016, Sep 19, 2023.

  1. Blastom1016

    Blastom1016

    Joined:
    Oct 4, 2019
    Posts:
    11
    Currently, we are using models under different quality for different platforms. As far as I tested, the fileId of models, unlike prefabs, was determintric. So 2 models files with exactly the same structure - same hierarchy, meshes with the same names, materials with the same names, etc, would have exactly the same fileIds for each of Objects.
    But as we wanted low-performance platforms to have fewer MeshRenderers, we had to remove some of them on low-quality models. This caused dramatic change on fileIds of the model files.
    The problem accurately had been solved by "locking" the fileId via modifying the meta files.

    But I'm still curious about how the fileIds generated. As far as I tested, the root GameObject and root Transform would always be the same among all the models. But the ones under them were vastly different.
    Do anyone know this?
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    3,899
    You should not be relying on the file ID. This is undocumented internal .meta file info said to be random, thus unpredictable.

    The GUID as provided by the AssetDatabase gives you a way to uniquely reference an asset regardless of its location in the file structure, even beyond its absense (eg you can export it to a unitypackage, delete it, reimport the unitypackage, and the GUID will again point to the same asset).
     
  3. Blastom1016

    Blastom1016

    Joined:
    Oct 4, 2019
    Posts:
    11
    The fileIds of model fileIds were pretty presistent - root Transform will always be -8679921383154817045, if it has a child called Bip001, it's always -8396670001580682531.
    I've already played with those guid/fileId/serialization index, etc for a long time.
    Just want to grab some missing parts.