Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Google Play Achievements

Discussion in 'Scripting' started by Nixel2013, Nov 10, 2020.

  1. Nixel2013

    Nixel2013

    Joined:
    May 9, 2019
    Posts:
    139
    Hello, I have the following code:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using System;
    5. using GooglePlayGames;
    6. using GooglePlayGames.BasicApi;
    7.  
    8. public class PlayServices : MonoBehaviour
    9. {
    10.  
    11.     void Start()
    12.     {
    13.         DontDestroyOnLoad(this);
    14.         try
    15.         {
    16.             PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder().Build();
    17.             PlayGamesPlatform.InitializeInstance(config);
    18.             PlayGamesPlatform.DebugLogEnabled = true;
    19.             PlayGamesPlatform.Activate();
    20.             Social.localUser.Authenticate((bool success) => { });
    21.         }
    22.         catch (Exception exception)
    23.         {
    24.             Debug.Log(exception);
    25.         }
    26.     }
    27.  
    28.  
    29.     public void ShowLogro()
    30.     {
    31.         if (Social.localUser.authenticated)
    32.         {
    33.             Social.ShowAchievementsUI();
    34.         }
    35.     }
    36.  
    37.     public void DesbloquearLogroUno()
    38.     {
    39.         if (Social.localUser.authenticated)
    40.         {
    41.             Social.ReportProgress("My ID 1", 5f, success => { });
    42.         }
    43.     }
    44.  
    45.  
    46.  
    47.     public void DesbloquearLogroDos()
    48.     {
    49.         if (Social.localUser.authenticated)
    50.         {
    51.             Social.ReportProgress("My ID 2", 10f, success => { });
    52.         }
    53.     }
    54. }

    and a static apart

    Code (CSharp):
    1. public static class LogrosScriptManager
    2. {
    3.         public const string achievement_logro_de_prueba_2 = "My ID 2"; // <GPGSID>
    4.         public const string achievement_logro_de_prueba = "My ID 1"; // <GPGSID>
    5.  
    6. }
    what happens is that when you press any of the buttons so that the achievement is unlocked, nothing happens.
    I would like to know where the error is, it is my first time with the whole issue this google play achievements.

    Obviously the "IDs" are not those.
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,724
    Do your strings match? Why declare
    const
    variables if you aren't going to use them elsewhere?

    Beyond that, I have no idea.
     
  3. ICE18

    ICE18

    Joined:
    Apr 9, 2021
    Posts:
    9