索引(从零开始)必须大于或等于零统一
Index (zero based) must be greater than or equal to zero unity
我需要这方面的帮助。它说在我的 logcat :
System.FormatException: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
这是我目前所做的。
1.) string full_path = string.Format("{0} {1}",Application.streamingAssetsPath + path_with_extention_under_streaming_assets_folder);
2.) string full_path = string.Format("{0}/{1}",Application.streamingAssetsPath + path_with_extention_under_streaming_assets_folder);
3.) string full_path = string.Format("{0}",Application.streamingAssetsPath + path_with_extention_under_streaming_assets_folder);
所有这些都不起作用。我的 logcat
仍然有错误
这是我的实际代码:
// Load 2 (StreamingAssets).
public static string LoadJsonFromStreamingAssets(string path_with_extention_under_streaming_assets_folder)
{
string json = null;
try
{
//Android Platform
#if UNITY_ANDROID
string full_path = string.Format("{0}/{1}",Application.streamingAssetsPath + path_with_extention_under_streaming_assets_folder);
// Android only use WWW to read file
WWW reader = new WWW(full_path);
while (!reader.isDone){}
json = reader.text;
// PK Debug 2017.12.11
Debug.Log("STEP 1. ");
Debug.Log(json);
JsonData itemData = JsonMapper.ToObject(json);
Debug.Log("STEP 2. ");
#else
string full_path = string.Format("{0}/{1}", Application.streamingAssetsPath, path_with_extention_under_streaming_assets_folder);
StreamReader reader = new StreamReader(full_path);
json = reader.ReadToEnd().Trim();
reader.Close();
#endif
}
catch (Exception e)
{
Debug.LogWarningFormat("Failed to Load.\n{0}\n{1}", e, path_with_extention_under_streaming_assets_folder);
}
return json;
}
我通过更改找到了解决方案:
string full_path = string.Format("{0}/{1}",Application.streamingAssetsPath + path_with_extention_under_streaming_assets_folder);
对此:
string full_path = string.Format("{0}/{1}",Application.streamingAssetsPath, path_with_extention_under_streaming_assets_folder);
我需要这方面的帮助。它说在我的 logcat :
System.FormatException: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
这是我目前所做的。
1.)
string full_path = string.Format("{0} {1}",Application.streamingAssetsPath + path_with_extention_under_streaming_assets_folder);
2.)
string full_path = string.Format("{0}/{1}",Application.streamingAssetsPath + path_with_extention_under_streaming_assets_folder);
3.)
string full_path = string.Format("{0}",Application.streamingAssetsPath + path_with_extention_under_streaming_assets_folder);
所有这些都不起作用。我的 logcat
仍然有错误这是我的实际代码:
// Load 2 (StreamingAssets).
public static string LoadJsonFromStreamingAssets(string path_with_extention_under_streaming_assets_folder)
{
string json = null;
try
{
//Android Platform
#if UNITY_ANDROID
string full_path = string.Format("{0}/{1}",Application.streamingAssetsPath + path_with_extention_under_streaming_assets_folder);
// Android only use WWW to read file
WWW reader = new WWW(full_path);
while (!reader.isDone){}
json = reader.text;
// PK Debug 2017.12.11
Debug.Log("STEP 1. ");
Debug.Log(json);
JsonData itemData = JsonMapper.ToObject(json);
Debug.Log("STEP 2. ");
#else
string full_path = string.Format("{0}/{1}", Application.streamingAssetsPath, path_with_extention_under_streaming_assets_folder);
StreamReader reader = new StreamReader(full_path);
json = reader.ReadToEnd().Trim();
reader.Close();
#endif
}
catch (Exception e)
{
Debug.LogWarningFormat("Failed to Load.\n{0}\n{1}", e, path_with_extention_under_streaming_assets_folder);
}
return json;
}
我通过更改找到了解决方案:
string full_path = string.Format("{0}/{1}",Application.streamingAssetsPath + path_with_extention_under_streaming_assets_folder);
对此:
string full_path = string.Format("{0}/{1}",Application.streamingAssetsPath, path_with_extention_under_streaming_assets_folder);