IEnumerator SendScore(string name, float elapsedTime) { ScoreInput scoreInput = new ScoreInput { name = name, elapsedTime = elapsedTime }; string rawInput = JsonUtility.ToJson(scoreInput); byte[] jsonBytes = Encoding.UTF8.GetBytes(rawInput); DownloadHandlerBuffer downloadHandlerBuffer = new DownloadHandlerBuffer(); UploadHandlerRaw uploadHandlerRaw = new UploadHandlerRaw(jsonBytes); uploadHandlerRaw.contentType = "application/json"; using (UnityWebRequest www = new UnityWebRequest(API_URL + "/scores", "POST", downloadHandlerBuffer, uploadHandlerRaw)) { yield return(www.SendWebRequest()); submitLoading = false; if (www.result != UnityWebRequest.Result.Success) { OnSubmitError(www.error); Debug.Log(www.error); } else { OnSubmitError(""); ScoreOutput myScoreOutput = new ScoreOutput { name = name, date = "", elapsedTime = elapsedTime }; currentScores.Add(myScoreOutput); currentScores.Sort((a, b) => - a.elapsedTime.CompareTo(b.elapsedTime)); RefreshScores(currentScores); submitForbidden = true; RefreshSubmitButtonInteractivity(); Debug.Log("Done uploading score"); } } }
private void ExtractResultsFromIntent() { // Load and unparcel scores IParcelable[] parcelableScores = this.Intent.GetParcelableArrayExtra(ExtraScores); ScoreOutput[] scores = new ScoreOutput[parcelableScores.Length]; for (int i = 0; i < parcelableScores.Length; i++) { scores[i] = ((ParcelableScoreOutput)parcelableScores[i]).Value; } // Load and unparcel CAMs IParcelable[] parcelableCAMs = this.Intent.GetParcelableArrayExtra(ExtraCAMs); CAM[] cams = new CAM[parcelableCAMs.Length]; for (int i = 0; i < parcelableCAMs.Length; i++) { cams[i] = ((ParcelableCAM)parcelableCAMs[i]).Value; } // Collapse into results array results = ResultsHelper.BuildConditionResultArray((ChestCondition[])Enum.GetValues(typeof(ChestCondition)), scores, cams, conditionColors); }
/// <summary> /// Initializes a new instance of <see cref="ConditionResult"/> with the provided data /// </summary> public ConditionResult(ChestCondition condition, ScoreOutput score, CAM cam) { Condition = condition; Score = score; CAM = cam; }
private ParcelableScoreOutput(Parcel parcel) { float likelihood = parcel.ReadFloat(); this.Value = new ScoreOutput(likelihood); }
/// <summary> /// Initializes a new instance of the <see cref="ParcelableScoreOutput"/> class to wrap the provided <see cref="ScoreOutput"/>. /// </summary> /// <param name="value">The <see cref="ScoreOutput"/> to wrap.</param> public ParcelableScoreOutput(ScoreOutput value) { this.Value = value; }