What is the reason of this error?

Assertion failed on expression: ‘m_CurrentHiddenGameObjects->find(gameObject.GetInstanceID()) == m_CurrentHiddenGameObjects->end()’

As described in error log, It is refers to “DontDestroyOnLoad” function. But I cannot find any helpful imformation about this . What is error mean?

4 Likes

I’d be interested in the same. Happened to me after upgrading from Unity 2017.x to 2019.1. Still looking for a way to get rid of this.

2 Likes

I had the same error. Seems to be linked to the fact that my object was hidden in the SceneVis tool. Error disappeared when I changes the visibility to show it again.

12 Likes

Thanks! Problem solved after changing the object to visible.

What is the SceneVis tool ? Is it some third-party tool?

Scene visibility - Unity - Manualdocs.unity3d.com › Manual › SceneVisibility

3 Likes

Thanks. I get it

This works for me:

private void Awake()
{
#if UNITY_EDITOR
    if (Application.isPlaying)
        UnityEditor.SceneVisibilityManager.instance.Show(gameObject, false);
#endif
    DontDestroyOnLoad(gameObject);
}
5 Likes

this fixed the problem for me! thank you

1 Like

The console was being spammed with this error for me as well every time I’d enter Play Mode. Deleting the Library folder then reopening the project solved it. 2022.2.0b3, Windows 10.

3 Likes

Thanks for this thread, the scene visibility was indeed the issue, and the code above fixed it!

Can’t believe the scene visibility affects runtime logic

1 Like

Please dont necro post. Use the like button to show appreciation.
Thread locked