Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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 MicroGT · Aug 06, 2015 at 04:56 PM · unity 5facebooknot workingloginintegration

Facebook integration problem

I've been trying to integrate facebook into my project and I've successfully managed to do just that with the help of some online tutorials however I do have one persisting problem...

The code is set to pause the game using

Time.timescale = 0; when a facebook window is up and to resume play using Time.timescale = 1; when it's not

but that just doesn't happen, and the function that pauses the game never gets called...

Here's the code :

 using UnityEngine;
 using UnityEngine.UI;
 using System.Collections;
 using System.Collections.Generic;
 
 public class FBHolder : MonoBehaviour {
 
     public GameObject UIFBIsLoggedIn;
     public GameObject UIFBNotLoggedIn;
     public GameObject UIFBAvatar;
     public GameObject UIFBUserName;
     
 
     public GameObject ScoreEntryPanel;
     public GameObject ScoreScrollList;
 
     private List<object> scoreslist = null;
 
     private Dictionary<string, string> profile = null;
 
     void Awake()
     {
         FB.Init (SetInit, onHideUnity);
     }
 
     private void SetInit()
     {
         Debug.Log ("FB Init Done");
 
         if(FB.IsLoggedIn)
             {
                 Debug.Log ("FB Logged In");
                 managefbmenus(true);
             }
         else
             {
                 managefbmenus(false);
             }
 
     }
 
     private void onHideUnity(bool isGameShown)
     {
         if(!isGameShown)
             {
                 Debug.Log ("Pause Game");
                 Time.timeScale = 0;
             }
         else
             {
                 Time.timeScale = 1;
             }
     }
 
     public void FBLogin()
     {
         FB.Login ("email,publish_actions", Authcallback);
     }
 
     void Authcallback(FBResult result)
     {
         if(FB.IsLoggedIn)
             {
                 Debug.Log ("FB Login Worked");
                 managefbmenus(true);
             }
         else
             {
                 Debug.Log ("FB Login Failed");
                 managefbmenus(false);
             }
     }
 
     void managefbmenus(bool isLoggedIn)
     {
         if(isLoggedIn)
             {
                 UIFBIsLoggedIn.SetActive(true);
                 UIFBNotLoggedIn.SetActive(false);
                 SetScore();
 
                 //Get profile picture
                 FB.API(Util.GetPictureURL("me", 128, 128), Facebook.HttpMethod.GET, DealWithProfilePicture);
                 FB.API("/me?fields=id,first_name", Facebook.HttpMethod.GET,DealwithUserName);
                 //Get username
             }
         if(!isLoggedIn)
             {
                 UIFBIsLoggedIn.SetActive(false);
                 UIFBNotLoggedIn.SetActive(true);
             }
     }
 
 
     void DealWithProfilePicture(FBResult result)
     {
         if(result.Error != null)
         {
             Debug.Log ("Problem getting profile picture");
             FB.API(Util.GetPictureURL("me", 128, 128), Facebook.HttpMethod.GET, DealWithProfilePicture);
             return;
         }
         Image UserAvatar = UIFBAvatar.GetComponent<Image> ();
         UserAvatar.sprite = Sprite.Create (result.Texture, new Rect(0, 0, 128, 128), new Vector2(0, 0));
     }
 
     void DealwithUserName(FBResult result)
     {
         if(result.Error != null)
         {
             Debug.Log ("Problem getting username");
             FB.API("/me?fields=id,first_name", Facebook.HttpMethod.GET,DealwithUserName);
             return;
         }
         profile = Util.DeserializeJSONProfile(result.Text);
 
         Text UserMsg = UIFBUserName.GetComponent<Text>();
 
         UserMsg.text = "Hello, " + profile ["first_name"];
     }
 



Any ideas on what could be causing this issue?

BTW: I'm using unity 5.

Comment
Add comment · Show 1
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 MicroGT · Aug 10, 2015 at 08:57 PM 0
Share

I really need help on this, can anybody help please?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Z2CSharp · Aug 27, 2015 at 01:28 AM

Here's what I did. Inside the function FBLogin() i set the timescale to 0. Then on the call back i set the timescale back to 1.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

unfortunately, app has stopped when trying to log into Facebook from mobile 1 Answer

Integration facebook with android unity 5 problem 0 Answers

Facebook Login and Logout problem 1 Answer

Problem Integration Facebook with Unity 5 On Android 0 Answers

facebook Login Script user_about_me, user_birthday", AuthCallback ??? not working! 0 Answers


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