Search Unity

[SOLVED] Google play games service loads a signing in box after every scene switch.

Discussion in 'Scripting' started by Etaodev, Dec 26, 2019.

  1. Etaodev

    Etaodev

    Joined:
    Dec 8, 2019
    Posts:
    13
    Hello,
    As the title proposes, how would I fix this problem? Currently, my project has two scenes, the gameobject that has the google play games api script is located in the first scene. Upon opening the game, the "connecting to plays services" message is prompted (which is good), but after switching to the second scene and coming back to the main scene, the "connecting to plays services" message is prompted again (which is not good). How can I only make it prompt upon opening the game, and not a scene change.

    My current code for the api gameobject is:
    Code (CSharp):
    1.     public void Start()
    2.     {
    3.  
    4.         PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder().Build();
    5.         PlayGamesPlatform.InitializeInstance(config);
    6.         PlayGamesPlatform.Activate();
    7.  
    8.         if (!Social.localUser.authenticated)
    9.             Social.localUser.Authenticate((bool success) => {});
    10.     }
    This code is from a post on stack overflow. But it doesn't seem to affect anything, it still pops up after every scene change.

    Is there any other method? Or is there something wrong with my code?.

    Please help!
     
    Last edited: Dec 26, 2019
  2. Dextozz

    Dextozz

    Joined:
    Apr 8, 2018
    Posts:
    493
    Would using a singleton help? It would allow you to maintain the same object in all the scenes in your game. I didn't really work with play services, but it should work.
     
  3. Etaodev

    Etaodev

    Joined:
    Dec 8, 2019
    Posts:
    13
    Thank you. This fixed the issue.
     
    Dextozz likes this.
  4. moonpower1

    moonpower1

    Joined:
    Dec 7, 2017
    Posts:
    7
    please share your final script .