- Home /
 
 
               Question by 
               Shadow Cleavens · Jul 29, 2015 at 11:42 AM · 
                saveloadgoogle play gamesdata storageclouddata  
              
 
              Can anybody help me with the google play api script?
Hi, i need a simple code to save on google cloud just with auto save and a load from cloud funtion here is my code :
     using UnityEngine;
     using System.Collections;
     using GooglePlayGames;   
     using UnityEngine.SocialPlatforms;  
     using GooglePlayGames.BasicApi.SavedGame;  
     using System;  
     using GooglePlayGames.BasicApi;   
     using UnityEngine.UI; 
 
 public class Googleplaysystem : MonoBehaviour { 
 
     public GameObject testmenu;   
     public int Score;  
     public int Live; 
     public int Power;
     public int Cash;
     
     
          void Awake () {
              PlayGamesPlatform.DebugLogEnabled = true;
              // Activate the Google Play Games platform
              PlayGamesPlatform.Activate();
              PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()
                  // enables legacy cloud save
                  .EnableDeprecatedCloudSave()
                      .EnableSavedGames()
                      .Build();
              PlayGamesPlatform.InitializeInstance(config);
          }
          
          
          void Start () {
              testmenu.SetActive(false);
              Social.localUser.Authenticate((bool success) =>{
                  if (success)
                  {
                      GameObject.Find("Status").GetComponent<Text>().text = "Conected";
                  }
                  else
                  {
                      GameObject.Find("Status").GetComponent<Text>().text = "Disconect";
                  }
              });
          }
          
        
          public void ArchivementUi () {
              Social.ShowAchievementsUI();
          }
 
          public void Leaderboard () {
              PlayGamesPlatform.Instance.ShowLeaderboardUI("LeaderboardId");
          }
 
 public void Save(){
     
     //for get the current values:
     
     Score = PlayerPrefs.GetInt("Score");
     Live = PlayerPrefs.GetInt("Live");
     Power = PlayerPrefs.GetInt("Power");   
     Cash = PlayerPrefs.GetInt("Cash");    
     SavetoCloud();
     
     void SavetoCloud(){
     
     //Do the save to cloud funtion to save Score,Cash, Power and Live.
     
     }
     
     public void LoadfromCloud(){
     
     Score = //ScorefromCloud
     Live = //LivefromCloud
     Power = //PowerfromCloud    
     Cash = //CashfromCloud    
 
      PlayerPrefs.SetInt("Score", Score);    
      PlayerPrefs.SetInt("Live",Live);
      PlayerPrefs.SetInt("Power", Power);
      PlayerPrefs.SetInt("Cash", Cash);
     
       }
     
     }
 
               Any help will be welcome.
               Comment
              
 
               
              Your answer
 
             Follow this Question
Related Questions
How to save or load higher score with google play services 0 Answers
Terrain: Use as scenario (individual) and prefab (unchanged, reusable) 0 Answers
how to save last position for the player before he die 2 Answers
What is the best way to save data on Android? 0 Answers
Saving and Loading Data with a for loop 2 Answers