unity3d - How can I match a GameObject to its resource ID in the .Unity scene file -


these file contents unity scene

--- !u!1 &341095427 gameobject:   m_objecthideflags: 0   m_prefabparentobject: {fileid: 143402, guid: e58d4c3907fdc484faf3ab7001288374, type: 2}   m_prefabinternal: {fileid: 0}   serializedversion: 4   m_component:   - 4: {fileid: 341095443}   m_layer: 8   m_name: main camera   m_tagstring: maincamera   m_icon: {fileid: 0}   m_navmeshlayer: 0   m_staticeditorflags: 0   m_isactive: 1 

the serialized resource id object on first line (341095427). script editor invoked unity menu. iterating through of gameobjects in active scene. there way above id gameobject? unfortunately getinstanceid() returns different value.

the first line asset local id. id resolved unity3d remapper , not accesible class , there no api this. getinstanceid got resolved id cached int, how tell id not ever same id check link extended of how work

you can use own uid , include in object:

public string id = guid.newguid().tostring();


Comments