Unity Parse Cloud函数调用 - ParseException InvalidCastException?

时间:2015-10-29 14:58:48

标签: android ios parse-platform unity3d

因此,我在Unity中调用Parse Cloud Code函数来获取子类ParseObjects的列表。但是无论何时运行它总是出错并且给我一个错误的InvalidCastException。

我已经尝试过发布here的解决方案,所以我已经定义了我想要的类型,但它仍然给我错误...

这是Unity C#中的相关功能:

// prepare the pre-queue list with needed filters
    IDictionary<string, object> fetchInfo = new Dictionary<string, object>
    {
        { "requestLimit", PHRASE_REQUEST_LIMIT }
    };

    var fetchTask = ParseCloud.CallFunctionAsync<IEnumerable<ParsePhrase>> ("FetchPhrases", fetchInfo);

    while (!fetchTask.IsCompleted) yield return null;

    if (fetchTask.IsFaulted || fetchTask.IsCanceled) 
    {
        using (IEnumerator<System.Exception> enumerator = fetchTask.Exception.InnerExceptions.GetEnumerator()) 
        {
            if (enumerator.MoveNext ()) 
            {
                ParseException exception = (ParseException)enumerator.Current;
                errorInfo = new ErrorInfo(ErrorType.ParseException, exception.Code);
            }
            else 
            {
                errorInfo = new ErrorInfo(ErrorType.ParseInternal);
            }
        }

        keeperState = KeeperState.Error;
        yield break;
    } 
    else
    {
        IEnumerable<ParsePhrase> result = fetchTask.Result;
        if(result != null)
        {
            string debugString = "query results: ";
            foreach(ParseObject parseObject in result)
            {
                debugString += parseObject.Get<string> ("correctMessage") + "|";
            }
            Debug.Log (debugString);
        }
        else
        {
            errorInfo = new ErrorInfo(ErrorType.ParseInternal);
            keeperState = KeeperState.Error;
            yield break;
        }
    }

此处还有相关的Cloud Code功能:

Parse.Cloud.define("FetchPhrases", function(request, response) {
  var requestLimit = request.params.requestLimit;

  if(typeof(requestLimit) != 'number')
    response.error("FetchPhrases: Invalid params");

  var query = new Parse.Query("Phrase");
  query.limit(requestLimit);
  query.find({
    success: function(results) {
      response.success(results);
    },
    error: function(error) {
      response.error(error);
    }
  });
});

请帮忙!

0 个答案:

没有答案