Скрипт по-разному работает в отладке и в билде
Есть скрипт, который должен формировать таблицу рекордов
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System;
public class Rescords : MonoBehaviour {
public string sTop1;
public string sTop2;
public string sTop3;
public string fileName = "SaveData";
public GUIText Top1;
public GUIText Top2;
public GUIText Top3;
// Use this for initialization
void Start () {
if (!File.Exists(Application.dataPath + "/" + fileName + ".txt")) {
FileInfo fi = new FileInfo(fileName + ".txt");
fi.Create();
sTop1 = "0";
sTop2 = "0";
sTop3 = "0";
SaveFile ();
}
LoadFile ();
Top1.text = "Top1: " + sTop1;
Top2.text = "Top2: " + sTop2;
Top3.text = "Top3: " + sTop3;
}
public void testRecords () {
GameController controller = GameObject.FindGameObjectWithTag ("GameController").GetComponent("GameController") as GameController;
if (controller.score > Int32.Parse(sTop3)){
if (controller.score > Int32.Parse (sTop2)) {
sTop3 = sTop2;
if (controller.score > Int32.Parse (sTop1)) {
sTop2 = sTop1;
sTop1 = controller.score.ToString();
} else {
sTop2 = controller.score.ToString();
}
} else {
sTop3 = controller.score.ToString();
}
}
SaveFile ();
}
void SaveFile() {
StreamWriter sw = new StreamWriter(Application.dataPath + "/" + fileName + ".txt");
sw.WriteLine(sTop1);
sw.WriteLine(sTop2);
sw.WriteLine(sTop3);
sw.Close();
}
void LoadFile() {
StreamReader streamReader = new StreamReader (Application.dataPath + "/" + fileName + ".txt");
if(File.Exists(Application.dataPath + "/" + fileName + ".txt")) {
sTop1 = streamReader.ReadLine();
sTop2 = streamReader.ReadLine();
sTop3 = streamReader.ReadLine();
}
}
}
В отладке в unity всё работает как надо, а в билде все три значения всегда одинаковы. Если значение controller.score больше чем сохранённое, все 3 значения становятся равным controller.score, а должно только одно