IEnumerator HandleCreateOrUpdate(UserScore score) { UnityWebRequest www = UnityWebRequest.Put("https://snake-api.glitch.me/v1/scores", score.ToJSONString()); www.SetRequestHeader("Content-Type", "application/json"); www.chunkedTransfer = false; www.method = "POST"; yield return(www.Send()); if (www.isNetworkError || www.isHttpError) { Debug.Log(www.error); } else { Debug.Log("Done!"); } }
public void CreateOrUpdateUserScore(UserScore score) { StartCoroutine(HandleCreateOrUpdate(score)); }