Version: Unity 6.1 Alpha (6000.1)
LanguageEnglish
  • C#

GlobalObjectId.targetPrefabId

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

public ulong targetPrefabId;

Description

The ID of the prefab instance that contains the referenced object.

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 (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

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961