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.Collections.Generic;
using System.IO; using System.IO;
using System.Xml; using System.Xml;
using UnityEngine;
namespace RothenburgAR.Common namespace RothenburgAR.Common
{ {
@@ -77,7 +77,18 @@ namespace RothenburgAR.Common
TextEntryType type = TextElement.GetTextEntryTypeFromString(typeStr); TextEntryType type = TextElement.GetTextEntryTypeFromString(typeStr);
var valueStr = xmlNode.Attributes["value"].Value; var valueStr = xmlNode.Attributes["value"].Value;
if (type == TextEntryType.File) 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); textElement.AddTextElement(langCode, type, valueStr);
} }
return textElement; return textElement;
@@ -104,15 +115,13 @@ namespace RothenburgAR.Common
if (Type == TextEntryType.Inline) if (Type == TextEntryType.Inline)
return Value; 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 it is no inline text, we need to have a file path as "value".
if (file == null) if (!File.Exists(Value))
throw new FileNotFoundException(); 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);
} }
} }

View File

@@ -39,6 +39,7 @@ GraphicsSettings:
- {fileID: 4800000, guid: 3a1c68c8292caf046bd21158886c5e40, type: 3} - {fileID: 4800000, guid: 3a1c68c8292caf046bd21158886c5e40, type: 3}
- {fileID: 207, guid: 0000000000000000f000000000000000, type: 0} - {fileID: 207, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 17000, guid: 0000000000000000f000000000000000, type: 0} - {fileID: 17000, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 16002, guid: 0000000000000000f000000000000000, type: 0}
m_PreloadedShaders: [] m_PreloadedShaders: []
m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000,
type: 0} type: 0}

View File

@@ -168,9 +168,9 @@ PlayerSettings:
AndroidPreferredInstallLocation: 1 AndroidPreferredInstallLocation: 1
aotOptions: aotOptions:
stripEngineCode: 1 stripEngineCode: 1
iPhoneStrippingLevel: 0 iPhoneStrippingLevel: 1
iPhoneScriptCallOptimization: 0 iPhoneScriptCallOptimization: 0
ForceInternetPermission: 0 ForceInternetPermission: 1
ForceSDCardPermission: 1 ForceSDCardPermission: 1
CreateWallpaper: 0 CreateWallpaper: 0
APKExpansionFiles: 0 APKExpansionFiles: 0
@@ -248,7 +248,7 @@ PlayerSettings:
AndroidKeystoreName: AndroidKeystoreName:
AndroidKeyaliasName: AndroidKeyaliasName:
AndroidTVCompatibility: 0 AndroidTVCompatibility: 0
AndroidIsGame: 1 AndroidIsGame: 0
AndroidEnableTango: 0 AndroidEnableTango: 0
androidEnableBanner: 1 androidEnableBanner: 1
androidUseLowAccuracyLocation: 0 androidUseLowAccuracyLocation: 0
@@ -271,6 +271,9 @@ PlayerSettings:
- m_BuildTarget: AndroidPlayer - m_BuildTarget: AndroidPlayer
m_APIs: 08000000 m_APIs: 08000000
m_Automatic: 0 m_Automatic: 0
- m_BuildTarget: iOSSupport
m_APIs: 08000000
m_Automatic: 0
m_BuildTargetVRSettings: [] m_BuildTargetVRSettings: []
m_BuildTargetEnableVuforiaSettings: m_BuildTargetEnableVuforiaSettings:
- m_BuildTarget: Android - m_BuildTarget: Android

Binary file not shown.