简体   繁体   中英

Facebook Android Unity can't post screenshot

I made a unity project and included facebook in it. Everything worked fine until I used OBB spliter.

Actually, I just wanted to share a screenshot of the game so I did this:

private void CallFBLogin()
{
    print ("test");
    FB.Login("email,publish_actions", LoginCallback);
    StartCoroutine (TakeScreenshot ());
    print ("test2");
}

When I push a button, this function is called but the problem is that the process finishes before I'm logged with Facebook. When I'm logged in, I'm already out of this function. What's the best way to log, wait to be logged and then launch the coroutine?

I haven't used the Facebook api yet so I can't give you exact code but based on what I see here you need to launch your coroutine from inside the LoginCallback function.

This way it will automatically execute after the user is logged in.

As TheValar stated, you need to do the following..

private void CallFBLogin()
{
    print ("test");
    FB.Login("email,publish_actions", MyLoginCallback);
    print ("test2");
}

void MyLoginCallback(FBResult result)
{
 // Do whatever you need, or nothing. You can check if you are logged in correctly
 StartCoroutine (TakeScreenshot ());
}

This will guarantee that the take screenshot gets called after you are logged in Facebook

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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