如何从Parse云函数返回ParseObjects列表到Unity?

时间:2016-01-20 00:13:57

标签: javascript c# parse-platform unity3d cloud

使用下面的代码,我可以将单个LeaderboardScore返回给Unity,但我想要做的是返回scoreResults并最终获得LeaderboardScores的列表统一。

我不确定我需要在Unity端指定哪种类型来实现这一点。我假设它IDictionary<string,object>[]只是t.IsFaulted,但是当我这样做时Parse.Cloud.define("getFriendsScores", function(request, response) { // code to get friends var scoresQuery = new Parse.Query("LeaderboardScore"); scoresQuery.containedIn("user", parseFriends); scoresQuery.find( { success: function(scoreResults) { response.success(scoreResults[0]); }, error: function(scoreError) { console.log('No matching scores found...'); } }); } 是真的,但是没有打印错误信息或代码(我认为它可能有一些麻烦转换为ParseException)。

如果有人能够对这里需要做的事情有所了解,我将非常感激:)

Cloud Code

ParseCloud.CallFunctionAsync<IDictionary<string, object>>("getFriendsScores", parameters).ContinueWith(t =>
{
    if (t.IsFaulted)
    {
        foreach (var e in t.Exception.InnerExceptions)
        {
            ParseException parseException = e as ParseException;
            Debug.Log("Error message " + parseException.Message);
            Debug.Log("Error code: " + parseException.Code);
        }
    }
    else
    {
        Debug.Log("Success!");
    }
});

Unity代码

<map>

1 个答案:

答案 0 :(得分:0)

通过在Unity中使用以下类型来管理它以使其工作:

<IList<IDictionary<string, object>>>

单个ParseObject作为实现IDictionary<string, object>的对象返回,当您要求列表时,它会为您提供一个列表(我只使用了IList,因为它更通用)。

对于其他任何努力弄清楚这类功能的返回类型的人来说,只需做这样的事情就可以解决问题:

ParseCloud.CallFunctionAsync<object>("functionName", parameters).ContinueWith(t =>
{
    Debug.Log(t.Result.GetType().ToString());
}