From 849c109ae26960be15722f01b9ea8230f4a2efc2 Mon Sep 17 00:00:00 2001 From: Alee Date: Mon, 10 Jun 2019 12:13:55 -0400 Subject: Localisation (Working progress) --- Assets/Scripts/Localisation/CSVLoader.cs | 68 ++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 Assets/Scripts/Localisation/CSVLoader.cs (limited to 'Assets/Scripts/Localisation/CSVLoader.cs') diff --git a/Assets/Scripts/Localisation/CSVLoader.cs b/Assets/Scripts/Localisation/CSVLoader.cs new file mode 100644 index 0000000..6805761 --- /dev/null +++ b/Assets/Scripts/Localisation/CSVLoader.cs @@ -0,0 +1,68 @@ +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("localisation"); + } + + public Dictionary GetDictionaryValues(string attributeID) + { + Dictionary dictionary = new Dictionary(); + + string[] lines = csvFile.text.Split(lineSeperator); + + int attributeIndex = -1; + + string[] headers = lines[0].Split(fieldSeperator, StringSplitOptions.None); + + for(int i=0; i attributeIndex) + { + var key = fields[0]; + + if (dictionary.ContainsKey(key)) { continue; } + + var value = fields[attributeIndex]; + + dictionary.Add(key, value); + } + } + + return dictionary; + } + +} -- cgit v1.2.3