private int GetIdInternal(Object target) { if (target == null) { return(0); } BiDictionary <int, Object> ids; Scene scene; var go = target.GameObject(); if (go != null) { scene = go.scene; if (!scene.IsValid()) { scene = default(Scene); } } else { scene = default(Scene); } if (!instanceIdsByScene.TryGetValue(scene, out ids)) { ids = new BiDictionary <int, Object>(); } int id = target.GetInstanceID(); ids[id] = target; return(id); }