I’ve tried searching Google, and this site, for a solution, but it seems like no-one has had this problem, and I don’t know if it’s something I’ve done (quite probably) or a bug in Unity.
Every time I load up a project (and normally after code is compiled) I get the following error in the console:
with the following code location shown at the bottom of the window
Assert in file: C:/BuildAgent/work/842f9557127e852/Runtime/Serialize/PersistentManager.cpp at line 1143
There was an old topic discussing some Assert errors at run time, but it didn’t seem to apply to my problem (which is happening in the editor, rather than at runtime).
Again, the error isn’t very descriptive, and I’ve been unable to figure out where the issue is arising from. It’s quite a large project and checking every script would be like looking for a needle in a haystack, especially since I don’t know where to start looking.
I realize this is an older thread, but I recently started getting this to happen as well. It seems to be related to dragging objects into EditorGUILayout.ObjectField() calls. Should we go to answers or just file a bug using Unity’s bugtracking system since this error comes internally from Unity itself?
I found there were some unnecessary objects in the scene that were throwing this, no indication of why or how but getting rid of them seems to have removed the issue.
For what it’s worth, we got the same issue in our project and it occured because our asset had “.unitypackage” in it’s filename. The asset’s full name was “Copy Project.unitypackage.asset”. After we renamed it to “Copy Project Package.asset” the error went away.
I don’t believe that’s the only source of the error, I’ve just had it start happening, no new assets added to the project, and no pre-existing assets with dodgy names. Seemed to start happening after a bad Unity crash (which I get periodically related to 3D corruption), but I can’t see any bad files in source control or loose in the ignored files. I did see an odd message about failure to deserialize something or other which I didn’t note down at the time, but I no longer see that, just the assert message.
I see it both at runtime (with a dozen or so at startup, even though I only load one extra scene), and in the editor. Runtime versions have no extra callstack, just:
!m_IsLoadingSceneFile PathIDToPathNameInternal(identifier.serializedFileIndex).find(“.unity”) != string::npos
I’m guessing from the assert logic, it’s complaining about loading an asset which it thinks is a .unity scene file, but the m_IsLoadingSceneFile flag isn’t set. Since I don’t have any assets that have .unity in their name other than scene files, maybe the PathIDToPathNameInternal function is coming up with the wrong asset name for the a particular file index, so all I can think is that the internal path name cache needs rebuilt. I have no idea how to actually do that though.
Ah, so I nuked my Library folder and suffered through a full asset reimport (which I’d hoped to avoid), and no joy. However, it did bring up the error I’d failed to note before:
Failed to unpersist: Not loaded ID: 75094 FileID: 1897581034
I get that as the only error in the asset reimport, almost at the end. Clearing the console then saving the main scene again causes 8 instances of the !m_IsLoadingSceneFile error, followed by the unpersist error again.
…
Aha! Found it - searching for the FileID in the scene file I tracked what those references were.
Turns out it was an instance of a prefab that I’d recently used GameObject->Break Prefab Instance on, to sever the connection between the in-scene objects and the prefab they were linked to. Turns out that ‘break’ is the operative word. Although the UI reflected that they weren’t linked to the prefab in any way any more, I could still find references to them in the scene file (specifically the m_PrefabParentObject still referenced the prefab, even though the m_PrefabInternal had been set to 0). Once I deleted the prefab (because I thought it was properly unlinked), the scene started to go haywire and giving the above error.
Manually editing the m_PrefabParentObject references out of the text .unity scene file to null out any reference to the deleted prefab seemed to work. I had to restart Unity to get rid of it entirely though, must have still been a lingering in-memory reference to it because the OnGUI variant of the message still happened even after I’d reloaded the scene. Hope that helps others if they’re coming across the issue