Version: 2021.3
LanguageEnglish
  • C#

GlobalObjectId

struct in UnityEditor

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

Description

Struct providing an API for stable, project-global object identifiers.

Provides a project-global object ID for lookup.

The ID is persistent and unique for a given Unity Object.

The format of the string representation of the ID is "GlobalObjectId_V1-{i}-{a}-{l}-{p}" where:
{i} is the identifier type represented by an integer (0 = Null, 1 = Imported Asset, 2 = Scene Object, 3 = Source Asset).
{a} is the asset GUID.
{l} is the local file ID of the object.
{p} is the prefab instance ID of the object.

The default null ID is "GlobalObjectId_V1-0-00000000000000000000000000000000-0-0".

Caveats:
- The ID changes when the object is moved to a new scene because the scene ID is part of the GlobalObjectID.

Properties

assetGUIDThe GUID for the asset to which this object belongs.
identifierTypeThe identifier type represented as an integer.
targetObjectIdThe local file ID of the object.
targetPrefabIdThe prefab instance id of the object.

Public Methods

EqualsCheck equality between two GlobalObjectIds.
ToStringGet the string representation of the GlobalObjectId.

Static Methods

GetGlobalObjectIdSlowConverts an Object reference or InstanceID to a GlobalObjectId.
GetGlobalObjectIdsSlowCreates an array of GlobalObjectIds based on an array of Objects or InstanceIDs.
GlobalObjectIdentifiersToInstanceIDsSlowCreates an array of InstanceIDs based on an array of GlobalObjectIds.
GlobalObjectIdentifiersToObjectsSlowCreates an array of Objects based on an array of GlobalObjectIds.
GlobalObjectIdentifierToInstanceIDSlowConverts a GlobalObjectId to an InstanceID.
GlobalObjectIdentifierToObjectSlowConverts a GlobalObjectId to an Object reference.
TryParseParses the string representation of a GlobalObjectId into a GlobalObjectId struct.