IEnumerator GoToSecletScene() { m_dataController.LoadLevelData(1); // 获取本关所用时间 m_currentTime = (int)m_timeController.GetComponent <TimeController>().m_currentTime; print("本关所用时间" + m_currentTime); // 获取所有当前关卡要存储的数据 封装到LevelData类中 m_starCount = SceneInfo.CalculateInfo(SubstringLevelName(m_sceneName) - 1, m_currentTime); print("得星个数" + m_starCount); // 封装用户数据 LevelData leveData = new LevelData(); leveData.Name = SubstringLevelName(m_sceneName); leveData.Score = SceneInfo.MScore; leveData.Time = m_currentTime; leveData.StarNum = m_starCount; // 加载本地数据 m_dataController.LoadJsonData(); int unLockPlayer = m_dataController.GetUnLockPlayer(); int unCurrentLevel = m_dataController.GetlevelCurrent(); // 判断是否保存场景数据 if (m_unLockPlayerNum > unLockPlayer || SubstringLevelName(m_sceneName) > unCurrentLevel) { // 保存数据 m_dataController.SaveData(m_unLockPlayerNum, SubstringLevelName(m_sceneName), leveData); } // 刷新SceneInfo类中的计分器 SceneInfo.UpdateInfo(); yield return(new WaitForSeconds(2)); // 场景切换 SceneManager.LoadScene("SelectCustoms"); }