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