Quantcast
Channel: Questions in topic: "javascipt"
Viewing all articles
Browse latest Browse all 1875

Can't get text file created by me (JavaScript)

$
0
0
Welcome, I have a problem with getting text files I created. I wanted my game to find all text files that contain language data, because I want my game to be multilingual. I created files "LanguageVersions.txt", "Polski.txt", "Slovensky.txt" and "English.txt" and wanted them (except the first one which is not listed) to be in that order. The problem is that I am not able to list them in order I want, because Unity can't get these files. ---------- I decided to create a string array which will get paths of all files in the directory and then reorder them. The code is below. I tried to do this by checking paths if they contain the name of the language file. It can only do it with English one. Can anyone help? ![alt text][1] Reader = new StreamReader (Application.dataPath + "/Localisations/LanguageVersions.txt" ); FileData = Reader.ReadToEnd(); Reader.Close (); FileLines = FileData.Split("\n"[0]); for (var i = 0; i < FileLines.Length; i++) { FileLine = FileLines[i]; if (!Languages.Contains (FileLine)) { if (FileLine.Contains ("")) { if (DefaultLanguage == "" ) { DefaultLanguage = FileLine; DefaultLanguage = DefaultLanguage.Replace ("", ""); DefaultLanguageID= i; } FileLine = FileLine.Replace ("", ""); } Languages.Add (FileLine); } } LanguagePaths = Directory.GetFiles (Application.dataPath + "/Localisations/", "*.txt"); LanguagePathsC = new String [Languages.Count]; for (var p : int = 0; p < Languages.Count; p++ ){ for (var lp : int = 0; lp < LanguagePaths.Length; lp++ ) { if (LanguagePaths [lp].Contains (Languages [p])) { LanguagePathsC [p] = LanguagePaths [lp]; } } } LanguagePaths = new String [LanguagePathsC.Length]; for (var lpn : int = 0; lpn < LanguagePathsC.Length; lpn++ ) LanguagePaths [lpn] = LanguagePathsC [lpn]; [1]: /storage/temp/90510-unitybug.png

Viewing all articles
Browse latest Browse all 1875

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>