Fixed error with new localization location

This commit is contained in:
2018-12-22 17:30:45 +01:00
parent 73a0ad4942
commit 3d9556c066
4 changed files with 25 additions and 12 deletions

View File

@@ -1,8 +1,8 @@
using UnityEngine;
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml;
using UnityEngine;
namespace RothenburgAR.Common
{
@@ -77,7 +77,18 @@ namespace RothenburgAR.Common
TextEntryType type = TextElement.GetTextEntryTypeFromString(typeStr);
var valueStr = xmlNode.Attributes["value"].Value;
if (type == TextEntryType.File)
valueStr = valueStr;
{
var file = Resources.Load<TextAsset>(valueStr);
if (file != null)
{
valueStr = file.text;
type = TextEntryType.Inline;
}
else
{
valueStr = Path.Combine(basePath, valueStr);
}
}
textElement.AddTextElement(langCode, type, valueStr);
}
return textElement;
@@ -104,15 +115,13 @@ namespace RothenburgAR.Common
if (Type == TextEntryType.Inline)
return Value;
// Attention:
// if there should be performance issues, here could be a nice place to add caching
var file = Resources.Load<TextAsset>(Value);
// If it is no inline text, we need to have a file path as "value".
if (file == null)
if (!File.Exists(Value))
throw new FileNotFoundException();
return file.text;
// Attention:
// if there should be performance issues, here could be a nice place to add caching
return File.ReadAllText(Value, System.Text.Encoding.UTF8);
}
}