Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by paranoiks · Oct 25, 2013 at 03:49 PM · webplayerfacebook

"Facebook object not loaded yet" error

When I try to run

FB.Login("email,publish_actions", LoginCallback)

I get this error:

NullReferenceException: Facebook object is not yet loaded. Did you call FB.Init()? FB.get_FacebookImpl () (at Assets/Facebook/Scripts/FB.cs:23) FB.Login (System.String scope, Facebook.FacebookDelegate callback) (at Assets/Facebook/Scripts/FB.cs:111) Controller.Start () (at Assets/Scripts/Controller.cs:27)

I am running FB.Init (SetInit, OnUnityHide) and my SetInit and OnUnityHide functions are:

 private void SetInit()
 {
     enabled = true;
 }
     
 private void OnUnityHide(bool isGameShown)
 {
     if(!isGameShown)
     {
         Time.timeScale = 0;
     }
     else
     {
         Time.timeScale = 1;
     }
 }
Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image jacksmash2012 · Oct 25, 2013 at 05:41 PM 0
Share

are you absolutely sure that you are not calling FB.Login before FB.Init responds via the callback function?

avatar image paranoiks · Oct 26, 2013 at 01:02 PM 0
Share

I don't know how to check whether Init() has responded. What I am doing now is: FB.Init (SetInit, OnUnityHide); if(!FB.IsLoggedIn) { FB.Login("email,publish_actions", LoginCallback); }

avatar image jacksmash2012 · Oct 26, 2013 at 03:16 PM 0
Share

According to your code above, the SetInit callback function will be called when Facebook has properly initialized. It is only then that you can attempt to log in.

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Swaminathan · Feb 18, 2014 at 12:12 PM

Sample code.. Do like this

In a fresh new script copy paste this and try deploy it in a device.

private void CallFBInit()

{

 FB.Init(OnInitComplete, OnHideUnity);

}

private void OnInitComplete()

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

private void OnHideUnity(bool isGameShown)

     {
         Debug.Log("Is game showing? " + isGameShown);
     }

private void CallFBLogin()

     {
         FB.Login("email", LoginCallback);
     }

private void LoginCallback(FBResult result)

     {
         if (result.Error != null)
             print("Logged In");
         else if (!FB.IsLoggedIn) {
             print("Failed");
         }
     }

NOTE TO REMEMBER :

  1. Call the CallFBInit() function in your void start.

  2. Call the CallFBLogin() function inside a button click. like this

    if(GUI.button)

{ CallFBLogin(); }

This will definetly work. but remember that you call CallFBInit() inside start.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Addyarb · Jan 22, 2016 at 03:33 PM

My issue was that I was deriving from a script that called FB.Init(), so it was being called twice which apparently un-initialized it.

A good way to debug this is to just write:

 void Start()
 {
 Debug.Log(gameObject);
 }

on one of your scripts that calls it. Then of course the one that inherits will also respond once you enter play mode.

However this won't work if you're not deriving from, but simply calling FB.Init() somewhere else. In that case you'll just have to track down said script.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by sollywon · Feb 25, 2018 at 11:21 AM

In my case, I turn the Facebook object off at Editor and just turn it on at runtime ([your object name].SetActive(true))and the error message is gone! also, this is my Facebook initialization code as below:

 private void Awake() 
     {
         if (!FB.IsInitialized) {
             FB.Init (() => {
                 if (FB.IsInitialized)
                     FB.ActivateApp ();
                 else
                     Debug.LogError ("Couldn't Initialized Facebook!");
             },
                 isGameShown => {
                     if (!isGameShown)
                         Time.timeScale = 0;
                     else
                         Time.timeScale = 1;
                 });
         } else {
             Debug.LogError ("Facebook Activate App");
             FB.ActivateApp ();
         }
     }

I hope it would be helpful!

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

19 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Facebook SDK 3.1.2 for Unity - Trouble logging in on Android Devices 1 Answer

Posting to Facebook wall using HttpMethod.POST unity3D 0 Answers

Problem integrating webplayer in Facebook 0 Answers

FB.Feed() "properties" argument not working as expected 0 Answers

Facebook Post to wall FB.Feed issue in Unity Facebook SDK 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges