4

I am using the Parse Unity SDK along with the Facebook Unity SDK in my game so users can log in with their Facebook account.

It's working well on mobiles (Android and iOS), and in the editor.

In Facebook Canvas (WebPlayer), on my machine (Mac Mini), with my main session (Administrator), with every browsers (Chrome, Safari, Firefox), I get an error upon calling this code :

Debug.Log("ABOUT TO LOGIN");
ParseFacebookUtils.LogInAsync(  FB.UserId,FB.AccessToken, 
                                      FB.AccessTokenExpiresAt).ContinueWith(x => 
{ 
    Debug.Log("IN TASK");
    if(x.IsFaulted || x.IsCanceled)
    {
        Debug.LogError("[FacebookManager] Error LogInAsync");
        Debug.Log(x.Exception);
    }
    else
    {
         // Connection successful
         // ...
    }
} 

// CODE CONTINUES...

The output is as follows :

ABOUT TO LOGIN

TrySetSetString can only be called from the main thread.
Constructors and field initializers will be executed from the loading thread when loading a scene.
Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function.

IN TASK

[FacebookManager] Error LogInAsync

System.AggregateException: Exception of type 'System.AggregateException' was thrown.
---------
System.ArgumentException: TrySetSetString can only be called from the main thread.
Constructors and field initializers will be executed from the loading thread when loading a scene.
Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function.
  at (wrapper managed-to-native) UnityEngine.PlayerPrefs:TrySetSetString (string,string)
  at UnityEngine.PlayerPrefs.SetString(System.String key, System.String value)[0x00000] in /Applications/buildAgent/work/___SOME_ID____/artifacts/WebPlayerGenerated/PlayerPrefsBinding.cs:62
  at Parse.PlatformHooks+SettingWrapper.Save()[0x00000] in <filename unknown>:0
  at Parse.PlatformHooks+SettingWrapper.set_Item (System.String key, System.Object value) [0x00000] in <filename_unknown>:0
  at Parse.ParseUser.SaveCurrentUser(Parse.ParseUser user) [0x00000] in <filename unkwnown>:0
  at Parse.ParseUser.<SignUpAsync>b__0 (Sustem.Threading.Tasks.Task _) [0x00000] in <filename unknown>:0
  at Parse.Internal.InternalExtensions+<>c__DisplayClassa.<OnSuccess>b__9 (System.Threading.Tasks.Task t) [0x00000] in <filename unknown>:0
  at Parse.Internal.InternalExtensions+<>c__DisplayClass7`1[System.Object].<OnSuccess>b__6 (System.Threading.Tasks.Task t) [0x00000] in <filename unknown>:0
  at System.Threading.Tasks.Task+<>c__DisplayClass3`1+<>c__DisplayClass5[System.Threading.Tasks.Task`1[System.Object]].<ContinueWith>b__2 () [0x00000] in <filename unknown>:0

This error doesn't appear on other sessions on my machine, and it doesn't appear on my teammates' machines either.

Here is what I tried so far (not necessarily in that order) :

  • Cleared browsers caches
  • Tried in private navigation mode
  • Going to unity3d.com/webplayer/setup to delete all cached files
  • Going to unity3d.com/webplayer/setup to disable caching of files
  • Uninstalling and fresh install of the Unity Web Player (downloaded from Chrome)
  • Uninstalling and fresh install of the Unity Web Player (downloaded from Firefox)
  • Deleted all WebPlayerPrefs on my machine
  • Changed permissions of PlayerPrefs folder and files to rw for everyone
  • Uninstalling Unity Web Player, Copy of the Unity Web Player files from the mac where the error doesn't appear to install manually
  • Including PlayerPrefs.DeleteAll()` in my code before LogInAsync

Additionaly, there are numerous times where the game doesn't even load (blank canvas instead of Game Logo + loading bar). Blank web player also happens sometimes when going to unity3d.com/webplayer/setup.

I am fairly certain that the problem comes either from a permission conflict, or a cache I don't know of.

Any idea what I can try now ?

4

2 に答える 2

3

同じ問題が発生しました。私の場合、問題は Web Player Development Release Channel にありました。開発チャンネルからリリース チャンネルに切り替えてみてください。

Unity ドキュメントから

http://docs.unity3d.com/Manual/WebPlayerChannels.html

于 2014-10-10T13:56:51.423 に答える
1

他の何かでこのエラーが発生し、宣言と代入を同時に行おうとすると TrySetSetString が起動することがわかりました。おそらく、クラス宣言の先頭にこのようなものがあります

ParseObject userInfo = new ParseObject("UserInfo");

これにより同じエラーが発生しましたが、削除するとエラーはなくなりました。これで問題が解決することを願っています。

于 2014-10-14T05:14:57.673 に答える