1
votes

I have tried changing the InteractiveConsole script that comes with the Facebook/Unity SDK to simply make it use Login via the facebook account, as a start. Before building for the web it works fine (inside Unity), I get the access token window and I can see my own facebook ID in the console afterwards. But when I build it for the web and click on the same login button nothing happens. I have no idea why. Here's my code:

using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

public sealed class InteractiveConsole : MonoBehaviour
{
    #region FB.Init() example

    private void CallFBInit()
    {
    FB.Init(OnInitComplete, OnHideUnity);
    }

    private void OnInitComplete()
    {
        Debug.Log("FB.Init completed: Is user logged in? " + FB.IsLoggedIn);
        CallFBLogin ();
    }

    private void OnHideUnity(bool isGameShown)
    {
        Debug.Log("Is game showing? " + isGameShown);
    }

    #endregion

    #region FB.Login() example

    private void CallFBLogin()
    {
        FB.Login("email,publish_actions", LoginCallback);
    }

    void LoginCallback(FBResult result)
    {
        if (!FB.IsLoggedIn)
        {
            Debug.Log ("User cancelled login.");
        }
        else
        {
            Debug.Log ("User ID: " + FB.UserId);
            if(FB.IsLoggedIn)
                Application.LoadLevel("main");
        }
    }

    #endregion

    void OnGUI()
    {
        if (Button("Login"))
        {
            CallFBInit();
        }
    }
    private bool Button(string label)
    {
        return GUILayout.Button(
            label
            );
    }
}

I'm sure I'm missing something. Can someone tell me what's wrong?

There's more I'd like to understand, is the Access Token Unity window there to replace the usual Login/Asking for Permissions window in the final game (as seen in basically every app used on facebook)? If not, how do I get the proper Login window?

1

1 Answers

0
votes

I've the same problem, however I did find a way to make it work. If you directly link to the Unity Binary URL instead of linking to a secure Canvas page you should be able to login. However I don't know how to change the looks of the page around the unity3D application.