Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


targetPrefabId

The ID of the prefab instance that contains the referenced object.
Read time 1 minuteLast updated 4 days ago

Definition

  • Type: Property
  • Namespace: UnityEditor
  • Assembly: UnityEditor
public ulong targetPrefabId { get; }

Remarks

Adding a new prefab instance to a scene creates a new instance of every object the prefab contains, including every GameObject. The GameObject inside a prefab instance doesn't have its own stable local file ID and a single prefab can be instantiated multiple times in a scene. Therefore, to reliably identify a GameObject that's part of a prefab requires both the local file ID of the original version of the GameObject (targetObjectId) and the ID of the particular prefab instance it belongs to (
targetPrefabId
).
For more information on creating prefab instances, refer to Creating Prefabs in the Manual.
The
targetPrefabId
constitutes the
{p}
element in the string representation of a
GlobalObjectId
, the format of which is:
GlobalObjectId_V1-{i}-{a}-{l}-{p}
Additional Resources: PrefabUtility.IsPartOfAnyPrefab