Advertisement
Xom9ik

SetValue Unity

May 10th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.90 KB | None | 0 0
  1. [Serializable]
  2.     public class Player
  3.     {
  4.         public string username;
  5.         public string email;
  6.         public string uid;
  7.  
  8.         public string game_data_json0;
  9.         public string game_data_json1;
  10.         public string game_data_json2;
  11.         public string game_data_json3;
  12.     }
  13. // Get cookies using GetCookie Jslib
  14. public string UID = "pirUJjkkId"; // Example
  15. public Player player;
  16.  
  17.  
  18. public IEnumerator SetScore()
  19.     {      
  20.         WWWForm form = new WWWForm ();
  21.         player.uid = UID;
  22.         player.game_data_json0 = JsonUtility.ToJson (player, true); // Example
  23.         Debug.Log ("I set: " + player.uid);
  24.         string json = JsonUtility.ToJson (player, true);
  25.         form.AddField ("arrayData", json);
  26. //CHANGE
  27.         WWW www = new WWW ("http://example-name.com/db-unity/SetValue.php", form);
  28.         yield return www;
  29.         if (www.error != null) {
  30.             Debug.Log ("Error: " + www.error);
  31.             yield break;
  32.         } else {   
  33.             Debug.Log ("Response: " + www.text);
  34.         }
  35.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement