Added back api call for getting English names
removed downloaded text caching?
This commit is contained in:
@@ -7,25 +7,17 @@ public class UmaViewerDownload : MonoBehaviour
|
|||||||
{
|
{
|
||||||
public static IEnumerator DownloadText(string url, System.Action<string> callback)
|
public static IEnumerator DownloadText(string url, System.Action<string> callback)
|
||||||
{
|
{
|
||||||
if (PlayerPrefs.GetString(url, "")=="")
|
UnityWebRequest www = UnityWebRequest.Get(url);
|
||||||
{
|
yield return www.SendWebRequest();
|
||||||
UnityWebRequest www = UnityWebRequest.Get(url);
|
|
||||||
yield return www.SendWebRequest();
|
|
||||||
|
|
||||||
if (www.result != UnityWebRequest.Result.Success)
|
if (www.result != UnityWebRequest.Result.Success)
|
||||||
{
|
{
|
||||||
Debug.Log(www.error);
|
Debug.Log(www.error);
|
||||||
}
|
callback("");
|
||||||
else
|
|
||||||
{
|
|
||||||
PlayerPrefs.SetString(url, www.downloadHandler.text);
|
|
||||||
callback(www.downloadHandler.text);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
callback(PlayerPrefs.GetString(url, ""));
|
callback(www.downloadHandler.text);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ using System.IO;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using System;
|
using System;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using System.Collections;
|
||||||
|
|
||||||
public class UmaViewerMain : MonoBehaviour
|
public class UmaViewerMain : MonoBehaviour
|
||||||
{
|
{
|
||||||
@@ -31,8 +33,22 @@ public class UmaViewerMain : MonoBehaviour
|
|||||||
AbSounds = AbList.Where(ab => ab.Name.EndsWith(".awb") || ab.Name.EndsWith(".acb")).ToList();
|
AbSounds = AbList.Where(ab => ab.Name.EndsWith(".awb") || ab.Name.EndsWith(".acb")).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Start()
|
private IEnumerator Start()
|
||||||
{
|
{
|
||||||
|
Dictionary<int, string> enNames = new Dictionary<int, string>();
|
||||||
|
yield return UmaViewerDownload.DownloadText("https://www.tracenacademy.com/api/BasicCharaDataInfo", txt =>
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(txt)) return;
|
||||||
|
var umaData = JArray.Parse(txt);
|
||||||
|
foreach (var item in umaData)
|
||||||
|
{
|
||||||
|
if (!enNames.ContainsKey((int)item["charaId"]))
|
||||||
|
{
|
||||||
|
enNames.Add((int)item["charaId"], item["charaNameEnglish"].ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
var UmaCharaData = UmaDatabaseController.Instance.CharaData;
|
var UmaCharaData = UmaDatabaseController.Instance.CharaData;
|
||||||
foreach (var item in UmaCharaData)
|
foreach (var item in UmaCharaData)
|
||||||
{
|
{
|
||||||
@@ -41,7 +57,7 @@ public class UmaViewerMain : MonoBehaviour
|
|||||||
{
|
{
|
||||||
Characters.Add(new CharaEntry()
|
Characters.Add(new CharaEntry()
|
||||||
{
|
{
|
||||||
Name = item["charaname"].ToString(),
|
Name = enNames.ContainsKey(id)? enNames[id] : item["charaname"].ToString(),
|
||||||
Icon = UmaViewerBuilder.Instance.LoadCharaIcon(id.ToString()),
|
Icon = UmaViewerBuilder.Instance.LoadCharaIcon(id.ToString()),
|
||||||
Id = id
|
Id = id
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user