//结束考核时调用 private void StopTest() { sw.Stop(); //停止计时 Grade grade = new Grade //记录成绩 { CorrectCount = correctCount, UsingTime = sw.ElapsedMilliseconds / 1000.0 }; SaveModel.GetInstance().AddGrade(grade); SceneManager.LoadScene("Result"); }
void Start() { SaveModel save = SaveModel.GetInstance(); interval = new Vector3(0, -1.4f, 0); Grade currentGrade = save.GetCurrentGrade(); currentCorrectCount.text = currentGrade.CorrectCount.ToString(); currentUsingTime.text = currentGrade.UsingTime.ToString(); SaveModel.GetInstance().SortGrade(); Vector3 initPosition = gradeOriginObject.transform.position; int count = save.AllGrades.Count > 5 ? 5 : save.AllGrades.Count; //排行榜上成绩最多5个 for (int i = 0; i < count; ++i) //循环显示所有成绩 { GameObject gradeObject = Instantiate(gradeOriginObject, initPosition + i * interval, Quaternion.identity); gradeObject.transform.parent = GameObject.Find("leaderboard").transform; SetGrade(gradeObject.transform, save.AllGrades[i], i + 1); } }
private void OnDestroy() { SaveModel.GetInstance().SaveFile();//存储成绩 }