- Home /
Question by
ina · Dec 23, 2010 at 07:02 AM ·
gameobjectinstantiateobjectreference
Reference by Instance ID?
Can you reference an object at runtime by instance ID? If not, what's the use of an instance ID?
Comment
Answer by Mike 3 · Dec 23, 2010 at 08:29 AM
No, don't think you can get an object by instance id (unless you have a map of instance id to object and put every object in the game into it)
Mainly it's used by the engine, but other uses are that it's used for GetHashCode, which in turn means that hashtables and dictionaries work without collisions, as well as general uses for debugging so you know which object is which
It's a pity EditorUtility.InstanceIDToObject ins't exposed in the UnityEngine namespace, but only in the UnityEditor namespace