2015-05-22 31 views
-1

今天是我第一天解析和我有我解決不了一個問題:解析查詢在Unity3D

我做了這個空白:

public void GetUserOfParse() 
{ 
    parseState = parseInfoState.BEFORE_QUERY; 
    int i = 0; 
    var userQuery = ParseObject.GetQuery("UserInfo").WhereEqualTo("userID", PlayGamesPlatform.Instance.GetUserId());  
    userQuery.FirstAsync().ContinueWith(t => 
    { 
     Debug.Log("in continuation"); 
    } 
} 

現在,如果我啓動項目在Unity編輯器中,它的工作效果非常好 - 在Unity Editor中PlayGamesPlatform.Instance.GetUserId()是'0',所以FirstAsync以user = 0返回我的ParseObject。 但是,當我嘗試在Android設備上啓動它時,FirstAsync沒有響應,它沒有進入ContinueWith,我沒有「繼續」調試。

我還需要做些什麼來使查詢在編輯器外工作? 感謝您的幫助!

回答

0

在沒有系統反饋的情況下排除故障非常困難;因此,我建議查看link以瞭解讓系統顯示錯誤代碼所需的內容。

在上面的鏈接中,這個代碼示例從頭部提供了幾個段落,這看起來像是一個開始調試問題的好地方。如果這個代碼可以用在你的解決方案中,你應該開始看到從這裏走到哪裏。

try 
{ 
    user.SignUpAsync().ContinueWith(t => { 
     if (t.IsFaulted) { 
      // Errors from Parse Cloud and network interactions 
      using (IEnumerator<System.Exception> enumerator = t.Exception.InnerExceptions.GetEnumerator()) { 
       if (enumerator.MoveNext()) { 
        ParseException error = (ParseException) enumerator.Current; 
        // error.Message will contain an error message 
        // error.Code will return "OtherCause" 
       } 
      } 
     } 
    }); 
} 
catch (InvalidOperationException e) 
{ 
    // Error from the SDK logic checks 
    // e.Message will contain the specific error 
    // ex: "Cannot sign up user with an empty name." 
} 

系統開始報告錯誤代碼,看看這個link找出這些錯誤代碼的意思是,以確定在故障排除過程中的下一步後。我希望這有幫助。

+0

在沒有設置用戶名和密碼的情況下,SignUpAsync會報告錯誤,但我想這是因爲在將數據發送到Parse數據庫之前已經檢查了錯誤。我也試過簡單的'var obj = new ParseObject(「obj1」); obj [「f1」] =「f1_Content」;在Unity編輯器中,並再次編譯爲exe文件,它工作正常,在android上它並不保存我的對象到服務器,並不會給我「保存」調試。 –

+0

問題解決了,我不小心將UnityEngine.dll複製到我的項目與Parse.Unity.dll –