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); } }