Since the InstanceID of an object may vary per session in Unity’s editor, is there any way to get the object corresponding to the local Id in file, instead?
I mean, something like EditorUtility.InstanceIDToObject but for the property “m_LocalIdentfierInFile”.
From: How to get the Local Identifier In File for scene objects
PropertyInfo inspectorModeInfo =
typeof(SerializedObject).GetProperty("inspectorMode", BindingFlags.NonPublic | BindingFlags.Instance);
SerializedObject serializedObject = new SerializedObject(unityObject);
inspectorModeInfo.SetValue(serializedObject, InspectorMode.Debug, null);
SerializedProperty localIdProp =
serializedObject.FindProperty("m_LocalIdentfierInFile"); //note the misspelling!
int localId = localIdProp.intValue;