简体   繁体   English

Unity Facebook SDK-登录问题

[英]Unity Facebook SDK - Login issue

I'm currently developing a game with Unity. 我目前正在使用Unity开发游戏。 My game is almost finished, and I want to add some Facebook features. 我的游戏快要完成了,我想添加一些Facebook功能。

I add the Facebook last SDK (5.2.1) to my C# project. 我将Facebook最后的SDK(5.2.1)添加到我的C#项目中。

Then, I add some functions, following the SmashFriends example : - FB.Init to Init the SDK - FB.Login to log the user - FB.Feed to post a story on the user timeline 然后,按照SmashFriends示例添加一些功能:-FB.Init初始化SDK-FB.Login登录用户-FB.Feed在用户时间线上发布故事

Basically, FB.Init is called when I start the game. 基本上,启动游戏时会调用FB.Init。 When the player finish his round, he got a score. 当玩家结束自己的回合时,他得到了一个分数。 Then, two choices : - User is already logged in, FB.Feed is called, with the score posted. 然后,有两个选择:-用户已经登录,调用FB.Feed,并发布分数。 - User isn't logged in -> Display the login popup -用户未登录->显示登录弹出窗口

Here's my problem : When I test it on Unity, the login popup display correctly, so I can enter my Access Token, and the Feed popup display, I can post. 这是我的问题:当我在Unity上对其进行测试时,将正确显示登录弹出窗口,因此我可以输入访问令牌,然后可以输入Feed弹出窗口。 But, when I test my app on Facebook (host on http://parseapp.com , no issue here), FB.Init is correctly called, and when FB.Login is called, I don't have any callback... 但是,当我在Facebook上测试我的应用程序(在http://parseapp.com上托管,在这里没有问题)时,FB.Init被正确调用,而在调用FB.Login时,我没有任何回调...

Precision : I use NGUI in my project. 精度:我在项目中使用NGUI。

I already searched the web, but found no solution =/ 我已经在网上搜索了,但是没有找到解决方案= /

It appears that in every scene you use a FB SDK functions, FB.Init should be called... After a day searching where was my error, I'm disappointed to see that it's not specified in the doc or nowhere else!! 似乎在每个使用FB SDK函数的场景中,都应该调用FB.Init。在一天搜索我的错误后,我很失望地看到它没有在文档中指定或在其他地方都没有指定!

Thanks to Stackoverflow corrector, to correct some parts of my questions! 感谢Stackoverflow校正器,可以更正我的部分问题! I'm sorry but I'm a french student ;) 抱歉,我是法国学生;)

I think you can also implement the facebook functionality as a singleton with a DoNotDestroy. 我认为您也可以使用DoNotDestroy将facebook功能实现为单例。 This should help you not loose init on switching scenes. 这应该有助于您不要在切换场景时松开init。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM