Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by iSPYwithFRIENDS · Jun 03, 2017 at 11:31 AM · facebookloginscriptable objectscene-changefunction call

How To: Scene Change After Facebook Login?

After Device Authentication and initializing with Gamesparks through the Splash Screen, my next scene has Facebook Login and Custom Login. I managed to make login through Facebook work but I have no idea how to implement a scene change upon completion. I tried using SceneManager.LoadLevel ( ) but I don't know how to tie it in to only activate after Facebook Login is successful. Just leaving it as is changes the scene even if I hit "Send Cancel" when asked for the Facebook Token.

So my question is, is it possible to trigger a scene change after the script successfully completes?

Here is the code for my Facebook Login:

 using UnityEngine;
 using UnityEngine.UI;
 using System.Collections;
 using System.Collections.Generic;
 using System;
 using GameSparks.Core;
 using GameSparks.Api;
 using GameSparks.Api.Responses;
 using GameSparks.Api.Requests;
 using Facebook;
 using Facebook.Unity;
 
 
 public class FacebookScript : MonoBehaviour
 {
 
 
 
     void Awake()
     {
         FB.Init(SetInit, OnHideUnity);
     }
 
     void SetInit()
     {
 
         if (FB.IsLoggedIn)
         {  GSFacebookLogin(AfterFBLogin);
             Debug.Log("FB is logged in");
         }
         
         else
         {
             Debug.Log("FB is not logged in");
         }
 
     }
 
     void OnHideUnity(bool isGameShown)
     {
 
         if (!isGameShown)
         {
             Time.timeScale = 0;
         }
         else
         {
             Time.timeScale = 1;
         }
 
     }
 
     public void FBlogin()
     {
 
         List<string> permissions = new List<string>();
         permissions.Add("public_profile");
         permissions.Add("user_friends");
 
         FB.LogInWithReadPermissions(permissions, AuthCallBack);
     }
 
     void AuthCallBack(IResult result)
     {
 
         if (result.Error != null)
         {
             Debug.Log(result.Error);
         }
         else
         {
             if (FB.IsLoggedIn)
             {
                 Debug.Log("FB is logged in");
             }
             else
             {
                 Debug.Log("FB is not logged in");
             }
         }
 
     }
     void GameSparksFBConnect(ILoginResult result)
     {
 
         if (FB.IsLoggedIn)
         {
             Debug.Log("Logging into gamesparks with facebook details");
             GSFacebookLogin(AfterFBLogin);
         }
         else
         {
             Debug.Log("Something wrong  with FB");
         }
     }
 
     //this is the callback that happens when gamesparks has been connected with FB
     private void AfterFBLogin(GameSparks.Api.Responses.AuthenticationResponse _resp)
     {
         Debug.Log(_resp.DisplayName);
     }
 
     //delegate for asynchronous callbacks
     public delegate void FacebookLoginCallback(AuthenticationResponse _resp);
 
 
     //This method will connect GS with FB
     public void GSFacebookLogin(FacebookLoginCallback _fbLoginCallback)
     {
         Debug.Log("");
 
         new GameSparks.Api.Requests.FacebookConnectRequest()
             .SetAccessToken(AccessToken.CurrentAccessToken.TokenString)
             .Send((response) =>
             {
                 if (!response.HasErrors)
                 {
                     Debug.Log("Logged into gamesparks with facebook");
                     _fbLoginCallback(response);
                 }
                 else
                 {
                     Debug.Log("Error Logging into facebook");
                 }
 
             });
     }
 
     
 }
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 iSPYwithFRIENDS · May 31, 2017 at 07:34 AM 0
Share

Found the solution; added the Scene$$anonymous$$anager.LoadScene(2) in the "if/else" statement on line 75. If anyone has a better way, let me know!

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by appvillas · Aug 29, 2018 at 06:18 AM

Just Add This to your Script.

  private void OnPlayfabFacebookAuthComplete(LoginResult result)
     {
         // SetMessage("PlayFab Facebook Auth Complete. Session ticket: " + result.SessionTicket);
        
         SceneManager.LoadScene("Main Menu");
     }

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

105 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 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 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 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 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

how can i use facebook authentication for pc games? 0 Answers

If you install the Google Play Game Plugin, you will not be able to sign in to Facebook. (iOS) 1 Answer

MarshalDirectiveException: Cannot marshal type 'System.Collections.Generic.IEnumerable`1' 4 Answers

Unity + Django + Facebook 0 Answers

Using Facebook Login unity Pc Build 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