I've got a bit of a weird issue going on right now. I am trying to load a localization json file from StreamingAssets. I am using Path.Combine to combine StreamingAssetsPath and Path together to form the full path. The value of Path is en-us. But for some reason Path.Combine is throwing a \ when concatting the strings so my path is invalid. If I change the value of Path to /en-US then it cuts the Application.StreamingAssetsPath portion off completely.
Debug.Log result of Path = en-US:
C:/Users/bluem/Documents/Fishtale/Assets/StreamingAssets\en-US
Debug.Log result of Path = /en-US
/en-US
I just cannot make heads or tales of this weirdness lol.
public void LoadLocalizedText()
{
localizedText = new Dictionary<string, string>();
string filePath = Path.Combine(Application.streamingAssetsPath, path);
Debug.Log(filePath);
if (File.Exists(filePath))
{
string dataAsJson = File.ReadAllText(filePath);
LocalizationData loadedData = JsonUtility.FromJson<LocalizationData>(dataAsJson);
for (int i = 0; i < loadedData.items.Length; i++)
{
localizedText.Add(loadedData.items[i].key, loadedData.items[i].value);
}
Debug.Log("Localization Manager: Data loaded, dictionary contains: " + localizedText.Count + " entries.");
}
else
{
Debug.LogError("Localization Manager: Cannot find data file name: " + filePath);
return;
}
isReady = true;
}