using System;
public class HelloWorld
{
public string UnityWebRequestJsonString(string fileName)
{
string url;
#region 分平台判断 StreamingAssets 路径
#if UNITY_EDITOR || UNITY_STANDALONE
url = "file://" + Application.dataPath + "/StreamingAssets/" + fileName;
#elif UNITY_IPHONE
url = "file://" + Application.dataPath + "/Raw/"+ fileName;
#elif UNITY_ANDROID
url = "jar:file://" + Application.dataPath + "!/assets/"+ fileName;
#endif
#endregion
UnityWebRequest request = UnityWebRequest.Get(url);
request.SendWebRequest();
while (true)
{
if (request.downloadHandler.isDone)
{
return request.downloadHandler.text;
}
}
}
}