如何从 Parse 云函数 return 到 Unity 的 ParseObjects 列表?

How do I return a list of ParseObjects to Unity from a Parse cloud function?

使用下面的代码,我能够 return 将单个 LeaderboardScore 返回到 Unity,但是我想要做的是 return scoreResults 并以 Unity 中的 LeaderboardScores 列表

我不确定我需要在 Unity 端指定什么类型才能实现这一点。我假设它只是 IDictionary<string,object>[],因为 Parse.Query.find returns an array of ParseObjects,但是当我这样做时 t.IsFaulted 是真的,但没有打印错误消息或代码(我认为它可能有一些问题转换为 ParseException)。

如果有人能阐明这里需要做什么,我将不胜感激:)

云码

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...');
        }
    });
}

统一码

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 中使用以下类型设法让它工作:

<IList<IDictionary<string, object>>>

单个 ParseObject returned 作为实现 IDictionary<string, object> 的对象,当您请求列表时,它会为您提供这些列表(我只是使用 IList,因为它更通用)。

对于那些努力弄清楚这些函数的 return 类型的人来说,只要做这样的事情,你就会解决这个问题:

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