ParseFacebookUtils.LogInAsync仅在WebPlayer上出错

时间:2014-09-30 13:03:11

标签: unity3d parse-platform facebook-unity-sdk unity-web-player

我在游戏中使用Parse Unity SDK和Facebook Unity SDK,因此用户可以使用他们的Facebook帐户登录。

它在移动设备(Android和iOS)以及编辑器中运行良好。

在Facebook Canvas(WebPlayer),我的主机(Mac Mini),我的主会话(管理员),每个浏览器(Chrome,Safari,Firefox)上,我在调用此代码时收到错误:

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...

输出如下:

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

此错误不会出现在我的计算机上的其他会话中,也不会出现在我的队友的计算机上。

这是我到目前为止所尝试的内容(不一定按此顺序):

  • 清除浏览器缓存
  • 在私人导航模式下尝试
  • 转到unity3d.com/webplayer/setup删除所有缓存的文件
  • 转到unity3d.com/webplayer/setup以禁用文件缓存
  • 卸载并全新安装Unity Web Player(从Chrome下载)
  • 卸载并全新安装Unity Web Player(从Firefox下载)
  • 删除了我机器上的所有WebPlayerPref
  • 将PlayerPrefs文件夹和文件的权限更改为每个人的rw
  • 卸载Unity Web Player,从未出现错误的mac手动安装Unity Web Player文件的副本
  • 在LogInAsync
  • 之前的代码中包含PlayerPrefs.DeleteAll()`

另外,有很多时候游戏甚至没有加载(空白画布而不是游戏徽标+加载栏)。 转到unity3d.com/webplayer/setup时,有时也会出现空白网页播放器。

我很确定问题来自权限冲突或我不知道的缓存。

知道我现在可以尝试什么吗?

2 个答案:

答案 0 :(得分:3)

我遇到了同样的问题。就我而言,问题出在Web Player开发版本频道中。尝试从开发频道切换到发布频道。

from Unity docs

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

答案 1 :(得分:1)

我在其他方面遇到了这个错误,当你试图同时进行声明和赋值时,事实证明TrySetSetString会激活。你可能在类声明的顶部有类似的东西

ParseObject userInfo = new ParseObject(&#34; UserInfo&#34;);

这给了我同样的错误但是当我删除它时,错误就消失了。希望这能解决你的问题。