- Home /
 
               Question by 
               Ronggowisnu · Aug 15, 2014 at 09:45 AM · 
                 
              
 
              Play Game Services plugin Save State Issue
I am using this plugin : https://github.com/playgameservices/play-games-plugin-for-unity
I am trying to save my local user's score to cloud, this is from the original guide :
    using GooglePlayGames;
     using UnityEngine.SocialPlatforms;
     using GooglePlayGames.BasicApi;
     public class MyClass : OnStateLoadedListener {
         void SaveState() {
             // serialize your game state to a byte array:
             byte[] mySaveState = ...;
             int slot = 0; // slot number to use
             ((PlayGamesPlatform) Social.Active).UpdateState(slot,
                 mySaveState, this);
         }
         public void OnStateSaved(bool success, int slot) {
             // handle success or failure
         }
         ...
My user score is an int, so this is what I did
 public void SaveState() {
         // serialize your game state to a byte array: //
         int TheHighScore = PlayerPrefs.GetInt ("highscore");
         byte[] mySaveState = System.BitConverter.GetBytes(TheHighScore);
         int slot = 0; // slot number to use
         ((PlayGamesPlatform)Social.Active).UpdateState(slot,mySaveState,this);
     }
     public void OnStateSaved(bool success, int slot) {
         // handle success or failure
     }
Then the error is :
 error CS1502: The best overloaded method match for `GooglePlayGames.PlayGamesPlatform.UpdateState(int, byte[], GooglePlayGames.BasicApi.OnStateLoadedListener)' has some invalid arguments
 
 error CS1503: Argument `#3' cannot convert `My CS Filename Whatever the name is' expression to type `GooglePlayGames.BasicApi.OnStateLoadedListener'
How to set this up correctly? it is always showing this error "my CS filename Whatever the name is" where ever I put it.
Note : I put this code in a normal CS file :
 using UnityEngine;
 using System.Collections;
 using GooglePlayGames.BasicApi;
 using GooglePlayGames;
 using UnityEngine.SocialPlatforms;
 
 public class blablabla : MonoBehaviour {
  
 bla bla bla ......
 
 }
thx
               Comment
              
 
               
              Answer by stefann16 · Dec 01, 2014 at 04:05 PM
You need to change this
 public class blablabla : MonoBehaviour {
to this
 public class blablabla : OnStateLoadedListener {
but i haven't figured out how to use it then.... did you?
I did it "then" but it didn't work other errors came lol
Your answer
 
 
             Follow this Question
Related Questions
How to get the user score value from Google Play Services Leaderboard? 8 Answers
Cloud recognition in Vuforia 0 Answers
Remove Component 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                