Unable to map prefab instance file id to a component in the prefab instance

Using the below yaml snippet for a prefab instance, I’ve been trying to find the actual transform component associated with the instance that has the m_LocalPosition.x property modified.
I used GlobalObjectId.GetGlobalObjectIdSlow() - Unity - Scripting API: GlobalObjectId on all components the prefab has but none of those return a negative value. How do i find which component is being referred to with the fileID “-8679921383154817045”

--- !u!1001 &662095253
PrefabInstance:
  m_ObjectHideFlags: 0
  serializedVersion: 2
  m_Modification:
    serializedVersion: 3
    m_TransformParent: {fileID: 0}
    m_Modifications:
    - target: {fileID: -8679921383154817045, guid: a35504593635b3f49adbda6a2f346835, type: 3}
      propertyPath: m_LocalPosition.x
      value: -2.09
      objectReference: {fileID: 0}
    - target: {fileID: -8679921383154817045, guid: a35504593635b3f49adbda6a2f346835, type: 3}
      propertyPath: m_LocalPosition.y
      value: 0
      objectReference: {fileID: 0}
    - target: {fileID: -8679921383154817045, guid: a35504593635b3f49adbda6a2f346835, type: 3}
      propertyPath: m_LocalPosition.z
      value: 0
      objectReference: {fileID: 0}
    - target: {fileID: -8679921383154817045, guid: a35504593635b3f49adbda6a2f346835, type: 3}
      propertyPath: m_LocalRotation.w
      value: 1
      objectReference: {fileID: 0}
    - target: {fileID: -8679921383154817045, guid: a35504593635b3f49adbda6a2f346835, type: 3}
      propertyPath: m_LocalRotation.x
      value: 0
      objectReference: {fileID: 0}
    - target: {fileID: -8679921383154817045, guid: a35504593635b3f49adbda6a2f346835, type: 3}
      propertyPath: m_LocalRotation.y
      value: 0
      objectReference: {fileID: 0}
    - target: {fileID: -8679921383154817045, guid: a35504593635b3f49adbda6a2f346835, type: 3}
      propertyPath: m_LocalRotation.z
      value: 0
      objectReference: {fileID: 0}
    - target: {fileID: -8679921383154817045, guid: a35504593635b3f49adbda6a2f346835, type: 3}
      propertyPath: m_LocalEulerAnglesHint.x
      value: 0
      objectReference: {fileID: 0}
    - target: {fileID: -8679921383154817045, guid: a35504593635b3f49adbda6a2f346835, type: 3}
      propertyPath: m_LocalEulerAnglesHint.y
      value: 0
      objectReference: {fileID: 0}
    - target: {fileID: -8679921383154817045, guid: a35504593635b3f49adbda6a2f346835, type: 3}
      propertyPath: m_LocalEulerAnglesHint.z
      value: 0
      objectReference: {fileID: 0}
    - target: {fileID: 919132149155446097, guid: a35504593635b3f49adbda6a2f346835, type: 3}
      propertyPath: m_Name
      value: monkeyWalking
      objectReference: {fileID: 0}
    - target: {fileID: 1630794972795428178, guid: a35504593635b3f49adbda6a2f346835, type: 3}
      propertyPath: m_UpdateWhenOffscreen
      value: 1
      objectReference: {fileID: 0}
    m_RemovedComponents: []
    m_RemovedGameObjects: []
    m_AddedGameObjects: []
    m_AddedComponents: []
  m_SourcePrefab: {fileID: 100100000, guid: a35504593635b3f49adbda6a2f346835, type: 3}

Completely stole this from Brave AI. The only credit I get is using your question as a prompt. lol
Enjoy

GlobalObjectId for Unpacked Prefabs

The GlobalObjectId struct in Unity does not directly support negative values for the targetObjectId property. When you convert a negative local file ID to a GlobalObjectId , the sign is lost because targetObjectId is an unsigned 64-bit value (ulong ). This means that any negative local file ID will be converted to a positive value.

Given the file ID “-8679921383154817045”, you can convert it to a positive value by simply taking the absolute value. However, this value alone is not sufficient to uniquely identify a component within a prefab, as it does not include the assetGUID or targetPrefabId which are also required to form a complete GlobalObjectId .

To find the specific component referred to by the file ID, you would need to construct a GlobalObjectId using the correct assetGUID and targetPrefabId for the prefab in question. Here is an example of how you might do this:

using UnityEngine;
using UnityEditor;

public class FindComponentExample
{
    public static void Main()
    {
        long fileId = -8679921383154817045;
        string assetGUID = "yourAssetGUID"; // Replace with the GUID of your prefab
        long targetPrefabId = 1234567890; // Replace with the correct targetPrefabId for your prefab

        // Convert the negative file ID to a positive value
        ulong positiveFileId = (ulong)(-fileId);

        // Construct the GlobalObjectId
        GlobalObjectId globalObjectId = new GlobalObjectId();
        globalObjectId.assetGUID = assetGUID;
        globalObjectId.targetObjectId = positiveFileId;
        globalObjectId.targetPrefabId = targetPrefabId;
        globalObjectId.identifierType = 2; // Assuming it's a scene object

        // Convert the GlobalObjectId back to an Object
        Object component = GlobalObjectId.GlobalObjectIdentifierToObjectSlow(globalObjectId);

        if (component != null)
        {
            Debug.Log("Found component: " + component.name);
        }
        else
        {
            Debug.Log("Component not found.");
        }
    }
}

This script assumes you know the assetGUID and targetPrefabId for the prefab. If you do not know these values, you will need to obtain them from the prefab or scene containing the component you are trying to locate.


Hope that helps!

Thanks, but this didn’t work :frowning: The right way to populate the fields of a GlobalObjectId instance would be by creating a string like so.

  long tempfileId = -8679921383154817045;
  string assetGUID = "a35504593635b3f49adbda6a2f346835";
  long targetPrefabId = 662095253;

  ulong positiveFileId = (ulong)(-tempfileId);

  string globalObjectIdString = $"GlobalObjectId_V1-2-{assetGUID}-{positiveFileId}-{targetPrefabId}";

  if (GlobalObjectId.TryParse(globalObjectIdString, out GlobalObjectId globalObjectId))
  {
      Debug.Log($"Successfully created GlobalObjectId: {globalObjectId}");
      Object component = GlobalObjectId.GlobalObjectIdentifierToObjectSlow(globalObjectId);
  }

component ends up being null in the above code.

the m_LocalPosition.x modification occurs in the transform of the fbx instance that i dragged into the scene. It’s global object identifier string is

"GlobalObjectId_V1-2-0b2540e2aa645d045986c3c4850fa361-9766822690554734571-662095253"

i cannot find those values anywhere in the yaml file. The asset guid is different, and so is the target object id. Only the target prefab id is the same as the one in the scene yaml file.