首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >索引(以零为基础)必须大于或等于零单位

索引(以零为基础)必须大于或等于零单位
EN

Stack Overflow用户
提问于 2017-12-11 08:35:08
回答 1查看 4.6K关注 0票数 1

我需要帮助处理这件事。上面写着我的逻辑猫:

System.FormatException:索引(基于零)必须大于或等于零,并且小于参数列表的大小。

到目前为止我是这样做的。

(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);

它们都不起作用。我的日志上还有个错误

这是我的实际代码:

代码语言:javascript
运行
复制
// 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;
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-12-11 08:54:04

我找到了解决办法,通过改变:

代码语言:javascript
运行
复制
string full_path = string.Format("{0}/{1}",Application.streamingAssetsPath + path_with_extention_under_streaming_assets_folder);

对此:

代码语言:javascript
运行
复制
string full_path = string.Format("{0}/{1}",Application.streamingAssetsPath, path_with_extention_under_streaming_assets_folder);
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47748988

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档