Unity File Formats: What does a fileID of a variant of a variant modification refer to?

I am trying to understand the Unity file formats. I created a prefab, which has only one component on it:

— !u!114 &5939202290990778263
MonoBehaviour:
testInt: 0

Then I created a variant and changed a value in the component:

  • target: {fileID: 5939202290990778263, guid: a655aa70e80bd9946b4ebcf606c0eeec, type: 3}
    propertyPath: testInt
    value: 1

So far so good! The fileID 5939202290990778263 is the same for both the updated value and the component on the original prefab. So that’s how the variant finds the component to update the value.

Then I created a variant of the variant and changed the value again:

  • target: {fileID: 7325023455698814560, guid: 090ae35bf447f4240bd7a3fd3e441164, type: 3}
    propertyPath: testInt
    value: 2

Uh oh. Where did the fileID: 7325023455698814560 come from? I searched my entire project and that fileID doesn’t appear anywhere else in any of my files! But clearly it’s working, because when I load the variant of the variant, the value is correct.

Does anyone know where or how Unity is going from this fileID to find the component when no other files have this fileID? It seems to be something specific to variants of variants but I can’t figure it out.

Thanks in advance.

Hi,
Variants are implemented as a particular case of Nested Prefabs. Because of this implementation choice override targets in Variants work in the same way as for Nested Prefabs.

Let’s take a simple Nested Prefab example:
nested.prefab

nestor.prefab

In this example there is only one override for each Nested instance - m_Name property, with nested_1 name for one instance and nested_2 name for the other instance. It is clear for which object this override must be applied in each PrefabInstance - the object with fileID 8663390130511716257 from the .prefab with GUID 1d06a8e36dd81c84f8c6a6e2f4010302. This is the same as in your first level Variant example.

Let’s take this a bit further. Now create an instance of nestor.prefab, it doesn’t matter if the instance is in a Scene or another Prefab and override the same property. For simplicity I will create a Variant of nestor.prefab:

nestorVariant.prefab:

In the context of nestorVariant.prefab we can’t use anymore the fileID 8663390130511716257 as override target for m_Name property because we must differentiate between the object with fileID 8663390130511716257 instantiated by PrefabInstance with fileID 778816605907768858 and the object with fileID 8663390130511716257 instantiated by PrefabInstance with fileID 3267956153526569644. To be able to differentiate the objects we xor the PrefabInstance fileID with the object fileID and this is how we obtain 6152083816908739853 and 8283354465948944827 fileIDs as targets.

We need this stable and reversible way of identifying Nested/Variant objects to be able to have a Prefab nested multiple times in other Prefabs and also for refactoring Prefabs, for example when a Prefab object is refactored as a Nested Prefab.
I hope this helps and clarifies a bit what is happening behind the scenes.