I’m loading an array by importing a text file that’s encoded with Unicode (UTF-8) using a script that executes in edit mode:
@script ExecuteInEditMode ()
var gameController : GameController;
var infoData : TextAsset;
var infoArray : Info[];
function Start () {
gameController.infoArray = InfoDataLoader();
}
function InfoDataLoader () {
var infoDataText = infoData.text;
var dynamicInfoArray = new Array ();
var infos = infoDataText.Split("#"[0]);
for (var info : String in infos) {
var infoDetails = info.Split("|"[0]);
currentInfo = new Info ();
var tempINT : String = infoDetails[0].ToString();
currentInfo.id = int.Parse(tempINT);
tempINT = infoDetails[1].ToString();
currentInfo.progress = int.Parse(tempINT);
currentInfo.title = infoDetails[2].ToString();
currentInfo.description = infoDetails[3].ToString();
currentInfo.hint = infoDetails[4].ToString();
currentInfo.summary = infoDetails[5].ToString();
currentInfo.congratulations = infoDetails[6].ToString();
tempINT = infoDetails[7].ToString();
if (tempINT != "")
currentInfo.nextInfo = int.Parse(tempINT);
dynamicInfoArray.Push (currentInfo);
}
// Copy the js array into a builtin array
infoArray = dynamicInfoArray.ToBuiltin(Info);
// To Check that the data has been pushed and copied to the final array
for (var checkInfo : Info in infoArray) {
// Debug.Log ("ID: " + checkInfo.id + " Title: " + checkInfo.title + " Start Progress: " + checkInfo.progress + "\n\nDescription: " + checkInfo.description + "\n\nHint: " + checkInfo.hint + "\n\nSummary: " + checkInfo.summary + "\n\nCongratulations: " + checkInfo.congratulations + "\n\nNext Info: " + checkInfo.nextInfo);
}
return infoArray;
}
Works fine with the exception of the paragraph / carriage return / line feed. This method just seems to ignore them.
The text runs together at the pr/cr/lf. I’ve tried changing the line endings in unitron to all the other choices in the men (afaict). I tried changing the line ending to \n but it just printed \n as text.
Any hints or suggestions?