问题:
using UnityEngine;
public class SceneChange : MonoBehaviour
{
void Start()
{
DontDestroyOnLoad(gameObject);
}
}
Assertion failed on expression: 'm_GameObjects.find(gameObject.GetInstanceID()) == m_GameObjects.end()'
UnityEngine.StackTraceUtility:ExtractStackTrace ()
解决方法:更改场景的可见性
方法一:
using UnityEngine;
public class SceneChange : MonoBehaviour
{
void Start()
{
#if UNITY_EDITOR
if (Application.isPlaying)
UnityEditor.SceneVisibilityManager.instance.Show(gameObject, false);
#endif
DontDestroyOnLoad(gameObject);
}
}
方法二:将场景设为可见