PrefabStage GlobalObjectId

In prefab stage when I try to call
GlobalObjectId.GlobalObjectIdentifierToObjectSlow(globalId)
where
globalId = GlobalObjectId.GetGlobalObjectIdSlow(Selection.activeTransform.gameObject)
I always get null. The activeTransform object is some child gameobject inside the open prefab in prefab mode.

Is there something I am missing or is it a bug?

1 Like

Hi! This looks like a bug in the GlobalObjectId API. Can you please create a bug by following these steps: https://support.unity.com/hc/en-us/articles/206336985-How-do-I-submit-a-bug-report-

Filed a bug report. Not sure if I should paste here the ticket number.

I noticed another (maybe related) thing that I added to the ticket:
Added gameobjects (modifications) in prefab instances and unsaved added gameobjects in Prefab mode have default null GlobalObjectsIds (GlobalObjectId_V1-0-00000000000000000000000000000000-0-0) which also seems as a bug.
There must be a way how to identify these objects, maybe somehow with PrefabUtility?

Another thing I found out and I think that might be the culprit:
GlobalObjectId.TryParse() method will not parse string to GID if GUID part is missing (=000000000000000000000000000000000)

Objects get an ID when the file containing them is saved and most likely this is why GlobalObjectId.GetGlobalObjectIdSlow returns a null GlobalObjectsId. You can force the objects to get an ID by saving the file.