ScoreList.cs 1009 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using System.IO;
  5. using UnityEngine.UI;
  6. public class ScoreList : MonoBehaviour {
  7. public Text Num;
  8. public Text level;
  9. public Text scorelist;
  10. public Text Name;
  11. void Awake () {
  12. FileStream ifr = new FileStream(Application.dataPath + "/ScoreList.txt", FileMode.OpenOrCreate);
  13. ifr.Close();
  14. string[] txts = File.ReadAllLines(Application.dataPath + "/ScoreList.txt");
  15. Num.text = "排名\n";
  16. level.text = "最高等级\n";
  17. scorelist.text = "分数\n";
  18. Name.text = "姓名\n";
  19. int num = 0;
  20. foreach (var t in txts)
  21. {
  22. if (num > 9) return;
  23. num++;
  24. string[] str = t.Split(',');
  25. Num.text += "<size=14>" + num+ "</size>\n";
  26. Name.text += str[0] + "\n";
  27. level.text += str[1]+"\n";
  28. scorelist.text += str[2]+"\n";
  29. }
  30. }
  31. }