Search Unity

How is fileID generated for m_CorrespondingSourceObject ?

Discussion in 'Prefabs' started by pushxtonotdie, Aug 12, 2019.

  1. pushxtonotdie

    pushxtonotdie

    Joined:
    Oct 21, 2010
    Posts:
    111
    Hi,

    I'm investigating an issue with prefab variants and and attempting to determine what is going on. If I do make some progress on this I will hopefully be able to create a repro (or perhaps you can tell me this is fixed in a later version of Unity and I can just upgrade).

    The issue is this: I have a prefab with a prefab variant nested inside it. I created this variant, added it, then connected up to the code via a reference. This created the following code at the bottom of the parent prefab:

    Code (csharp):
    1.  
    2. --- !u!114 &3075605346730906691 stripped
    3. MonoBehaviour:
    4.   m_CorrespondingSourceObject: {fileID: 6933667124208082087, guid: 583b983315f544810b2693d460bcfcde,
    5.     type: 3}
    6.   m_PrefabInstance: {fileID: 5375023374358153444}
    7.   m_PrefabAsset: {fileID: 0}
    8.   m_GameObject: {fileID: 0}
    9.   m_Enabled: 1
    10.   m_EditorHideFlags: 0
    11.   m_Script: {fileID: 11500000, guid: 461fcabef184540deb0b87352712d1dd, type: 3}
    12.   m_Name:
    13.   m_EditorClassIdentifier:
    14.  
    For whatever reason the fileID of 6933667124208082087 is incorrect. The correct number is 7038841995742994224. I determined this by copying the project except the Library/ and then re-attaching the script reference. I also did a Reimport All after I knew the correct value and found my original project broke in the same way. But why the fileID is incorrect I cannot understand, partially because I don't know how its generated. How is it made?
     
  2. SteenLund

    SteenLund

    Unity Technologies

    Joined:
    Jan 20, 2011
    Posts:
    639
    @pushxtonotdie

    For variants the FileID is the
    (FileID_of_PrefabInstance_in_variant ^ FileID_of_object_in_base_Prefab) & 0x7fffffffffffffff;
     
    Jojo59516_2 and chengyingzhilian like this.
  3. pushxtonotdie

    pushxtonotdie

    Joined:
    Oct 21, 2010
    Posts:
    111
    That was very, very helpful to know Steen, I appreciate it. While this dramatically sped up my bughunting this morning, I unfortunately could not get a repro. All my file id hashes checked out, and I couldn't find anything that matched the bad fileID of 6933667124208082087. What I did learn is that the FileID_of_PrefabInstance_in_variant is 6933667124208079258, which is 2829 off from the bad fileID. Those numbers are really close but I can't make heads or tails of it. I will have to file this under 'until next time it happens'.