diff options
| author | Andrew Lee <alee14498@gmail.com> | 2019-10-11 18:16:34 -0400 |
|---|---|---|
| committer | Andrew Lee <alee14498@gmail.com> | 2019-10-11 18:16:34 -0400 |
| commit | 93b5f588e3cb644f61e002932d61f2c6cdab87ab (patch) | |
| tree | 83025a2c02383512fe58792283482d6da184d36d /Assets/Scripts/Localisation/CSVLoader.cs | |
| parent | 65b90c5cd18702d0d6ca167fd264c3b495b2ee33 (diff) | |
| download | Unicity-93b5f588e3cb644f61e002932d61f2c6cdab87ab.tar.gz Unicity-93b5f588e3cb644f61e002932d61f2c6cdab87ab.tar.bz2 Unicity-93b5f588e3cb644f61e002932d61f2c6cdab87ab.zip | |
We finally got rid of GPL
Diffstat (limited to 'Assets/Scripts/Localisation/CSVLoader.cs')
| -rw-r--r-- | Assets/Scripts/Localisation/CSVLoader.cs | 68 |
1 files changed, 0 insertions, 68 deletions
diff --git a/Assets/Scripts/Localisation/CSVLoader.cs b/Assets/Scripts/Localisation/CSVLoader.cs deleted file mode 100644 index 6805761..0000000 --- a/Assets/Scripts/Localisation/CSVLoader.cs +++ /dev/null @@ -1,68 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Text.RegularExpressions; -using UnityEngine; - -public class CSVLoader -{ - //Reference file; - private TextAsset csvFile; - private char lineSeperator = '\n'; - private char surrond = '"'; - private string[] fieldSeperator = { "\", \"" }; - - public void LoadCSV() - { - csvFile = Resources.Load<TextAsset>("localisation"); - } - - public Dictionary<string, string> GetDictionaryValues(string attributeID) - { - Dictionary<string, string> dictionary = new Dictionary<string, string>(); - - string[] lines = csvFile.text.Split(lineSeperator); - - int attributeIndex = -1; - - string[] headers = lines[0].Split(fieldSeperator, StringSplitOptions.None); - - for(int i=0; i<headers.Length; i++) - { - if(headers[i].Contains(attributeID)) - { - attributeIndex = i; - break; - } - } - - Regex CSVParser = new Regex(",(?=(?:[^\"]*\"[^\"]*\")*(?![^\"]*\"))"); - - for(int i=1; i<lines.Length; i++) - { - string line = lines[i]; - - string[] fields = CSVParser.Split(line); - - for(int f=0; f<fields.Length; f++) - { - fields[f] = fields[f].TrimStart(' ', surrond); - fields[f] = fields[f].TrimEnd(surrond); - } - - if(fields.Length > attributeIndex) - { - var key = fields[0]; - - if (dictionary.ContainsKey(key)) { continue; } - - var value = fields[attributeIndex]; - - dictionary.Add(key, value); - } - } - - return dictionary; - } - -} |
