private void LoadWikiData() { _data = new Dictionary <string, WikiEntryData>(); var rawData = Resources.LoadAll <TextAsset>(WikiPath); rawData.ToList().ForEach(textAsset => { var wikiEntryData = new WikiEntryData(); var lines = textAsset.text.Split('\n').ToList(); lines.ForEach(line => { if (line.StartsWith("$")) { HandleCommand(line, wikiEntryData); } else { wikiEntryData.BodyText += line + "\n"; } }); try { _data.Add(wikiEntryData.Title, wikiEntryData); } catch (ArgumentNullException ex) { Debug.LogError("Tried to add a Wiki entry without a defined title. " + "(Text Asset: " + textAsset.name + ")"); Debug.LogError(ex); } }); }
private void HandleCommand(string line, WikiEntryData wikiEntryData) { var token = line.Trim().Trim('$').Split('='); var cmd = token[0].ToLower(); var arg = token[1]; switch (cmd) { case "title": wikiEntryData.Title = arg; break; default: return; } }