Hello I can't save my statistics player on the cloud because I have this error in the console
Assets/Scripts/PlayFabController.cs(266,19): error CS0103: The name 'JsonWrapper' does not exist in the current context
and this my code below
using System.Collections.Generic; using UnityEngine; using PlayFab; using PlayFab.ClientModels; using PlayFab.Json; public class PlayFabController : MonoBehaviour { // Static instance for this Class. public static PlayFabController PFC; private string userEmail = "s@gmail.com"; private string userPassword = "123456789"; private string myUserName = "jussien"; public GameObject loginPanel; public GameObject addLoginPanel; public GameObject recoverButton; // create singleton static. private void OnEnable() { if (PlayFabController.PFC == null) { PlayFabController.PFC = this; } else { if (PlayFabController.PFC != this) { Destroy(this.gameObject); } } DontDestroyOnLoad(this.gameObject); } public void Start() { //Note: Setting title Id here can be skipped if you have set the value in Editor Extensions already. if (string.IsNullOrEmpty(PlayFabSettings.TitleId)) { PlayFabSettings.TitleId = "7C8FB"; // Please change this value to your own titleId from PlayFab Game Manager } // to delete user date. //PlayerPrefs.DeleteAll(); //var request = new LoginWithCustomIDRequest { CustomId = "GettingStartedGuide", CreateAccount = true }; //PlayFabClientAPI.LoginWithCustomID(request, OnLoginSuccess, OnLoginFailure); if (PlayerPrefs.HasKey("EMAIL")) { userEmail = PlayerPrefs.GetString("EMAIL"); userPassword = PlayerPrefs.GetString("PASSWORD"); var request = new LoginWithEmailAddressRequest { Email = userEmail, Password = userPassword }; PlayFabClientAPI.LoginWithEmailAddress(request, OnLoginSuccess, OnLoginFailure); } // create account with Android ID without usieng email. else { #if UNITY_ANDROID var requestAndroid = new LoginWithAndroidDeviceIDRequest { AndroidDeviceId = ReturnMobileID(), CreateAccount = true }; PlayFabClientAPI.LoginWithAndroidDeviceID(requestAndroid, OnLoginMobieSuccess, OnLoginMobileFailure); #endif #if UNITY_IOS var requestIOS = new LoginWithIOSDeviceIDRequest { DeviceId = ReturnMobileID(), CreateAccount = true }; PlayFabClientAPI.LoginWithIOSDeviceID(requestIOS, OnLoginMobieSuccess, OnLoginMobileFailure); #endif } } #region Login // todo: login function private void OnLoginSuccess(LoginResult result) { Debug.Log("Congratulations, you made your first successful API call!"); // to save date of player when login again. PlayerPrefs.SetString("EMAIL", userEmail); PlayerPrefs.SetString("PASSWORD", userPassword); loginPanel.SetActive(false); recoverButton.SetActive(false); GetStats(); } // todo: failure func. private void OnLoginFailure(PlayFabError error) { var registerRequest = new RegisterPlayFabUserRequest { Email = userEmail, Password = userPassword, Username = myUserName }; PlayFabClientAPI.RegisterPlayFabUser(registerRequest, OnRegisterSuccess, OnRegisterFailure); } // todo: Registration func public void OnRegisterSuccess(RegisterPlayFabUserResult result) { Debug.Log("Congratulations. you made your first successful API"); // to save date of player when login again. PlayerPrefs.SetString("EMAIL", userEmail); PlayerPrefs.SetString("PASSWORD", userPassword); loginPanel.SetActive(false); GetStats(); } // todo: Resister Failure func. public void OnRegisterFailure(PlayFabError error) { Debug.LogError(error.GenerateErrorReport()); } // todo: login function private void OnLoginMobieSuccess(LoginResult result) { Debug.Log("Congratulations, you made your first successful API call!"); loginPanel.SetActive(false); GetStats(); } // todo: failure Android func. private void OnLoginMobileFailure(PlayFabError error) { Debug.Log(error.GenerateErrorReport()); } // todo: username func public void GetUserEmail(string emailIn) { userPassword = emailIn; } // todo: password func public void GetUserPassword(string passwordIn) { userPassword = passwordIn; } // todo: password func public void GetUserName(string userNameIn) { myUserName = userNameIn; } public void OnClickLogin() { var request = new LoginWithEmailAddressRequest { Email = userEmail, Password = userPassword }; PlayFabClientAPI.LoginWithEmailAddress(request, OnLoginSuccess, OnLoginFailure); } public static string ReturnMobileID() { string deviceID = SystemInfo.deviceUniqueIdentifier; return deviceID; } public void OpenAddLogin() { addLoginPanel.SetActive(true); } public void OnClickAddLogin() { var addLoginRequest = new AddUsernamePasswordRequest { Email = userEmail, Password = userPassword, Username = myUserName }; PlayFabClientAPI.AddUsernamePassword(addLoginRequest, OnAddLoginSuccess, OnRegisterFailure); } private void OnAddLoginSuccess(AddUsernamePasswordResult result) { Debug.Log("Congratulations, you made your first successful API call!"); PlayerPrefs.SetString("EMAIL", userEmail); PlayerPrefs.SetString("PASSWORD", userPassword); addLoginPanel.SetActive(false); } #endregion Login #region PlayerStats // Create Statistics Players. public int playerLevel; public int gameLevel; public int playerHealth; public int playerDamage; public int playerHighScore; // todo: function which Button Call it to set the values inside it. public void SetStats() { PlayFabClientAPI.UpdatePlayerStatistics(new UpdatePlayerStatisticsRequest { // request.Statistics is a list, so multiple StatisticUpdate objects can be defined if required. Statistics = new List<StatisticUpdate> { new StatisticUpdate { StatisticName = "PlayerLevel", Value = playerLevel }, new StatisticUpdate { StatisticName = "GameLevel", Value = gameLevel }, new StatisticUpdate { StatisticName = "PlayerHealth", Value = playerHealth }, new StatisticUpdate { StatisticName = "PlayerDamage", Value = playerDamage }, new StatisticUpdate { StatisticName = "PlayerHighScore", Value = playerHighScore }, } }, result => { Debug.Log("User statistics updated"); }, error => { Debug.LogError(error.GenerateErrorReport()); }); } void GetStats() { PlayFabClientAPI.GetPlayerStatistics( new GetPlayerStatisticsRequest(), OnGetStats, error => Debug.LogError(error.GenerateErrorReport()) ); } // todo: func which pass the values to SetStats(); function above void OnGetStats(GetPlayerStatisticsResult result) { Debug.Log("Received the following Statistics:"); foreach (var eachStat in result.Statistics) { Debug.Log("Statistic (" + eachStat.StatisticName + "): " + eachStat.Value); switch (eachStat.StatisticName) { case "PlayerLevel": playerLevel = eachStat.Value; break; case "GameLevel": gameLevel = eachStat.Value; break; case "PlayerHealth": playerHealth = eachStat.Value; break; case "PlayerDamage": playerDamage = eachStat.Value; break; case "PlayerHighScore": playerHighScore = eachStat.Value; break; } } } // Build the request object and access the API public void StartCloudUpdatePlayerStats() { PlayFabClientAPI.ExecuteCloudScript(new ExecuteCloudScriptRequest() { FunctionName = "UpdatePlayerStats", // Arbitrary function name (must exist in your uploaded cloud.js file) FunctionParameter = new { Level = playerLevel, highScore = playerHighScore, apple = 0 }, // The parameter provided to your function GeneratePlayStreamEvent = true, // Optional - Shows this event in PlayStream }, OnCloudUpdateStats, OnErrorShared); } // OnCloudHelloWorld defined in the next code block private static void OnCloudUpdateStats(ExecuteCloudScriptResult result) { // Cloud Script returns arbitrary results, so you have to evaluate them one step and one parameter at a time Debug.Log(JsonWrapper.SerializeObject(result.FunctionResult)); JsonObject jsonResult = (JsonObject)result.FunctionResult; object messageValue; jsonResult.TryGetValue("messageValue", out messageValue); // note how "messageValue" directly corresponds to the JSON values set in Cloud Script Debug.Log((string)messageValue); } private static void OnErrorShared(PlayFabError error) { Debug.Log(error.GenerateErrorReport()); } #endregion PlayerStats }