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 回答