private void CreateRankingEntryTransform(RankingEntry rankingEntry, Transform rankingContainer, List <Transform> transformList, bool ascending, int precision)
        {
            float rankingTemplateHeight = 30f;

            Transform     rankingTransform     = Instantiate(rankingTemplate, rankingContainer);
            RectTransform rankingRectTransform = rankingTransform.GetComponent <RectTransform>();

            rankingRectTransform.anchoredPosition = new Vector2(0, -rankingTemplateHeight * transformList.Count);
            rankingTransform.gameObject.SetActive(true);

            int ranking = transformList.Count + 1;

            switch (ranking)
            {
            default:
                break;

            case 1:
                if (!ascending)
                {
                    rankingTransform.Find("GoldMedal").gameObject.SetActive(true);
                }
                break;

            case 2:
                if (!ascending)
                {
                    rankingTransform.Find("SilverMedal").gameObject.SetActive(true);
                }
                break;

            case 3:
                if (!ascending)
                {
                    rankingTransform.Find("BronzeMedal").gameObject.SetActive(true);
                }
                break;
            }
            rankingTransform.Find("id").GetComponent <Text>().text = ranking.ToString();

            string userID = rankingEntry.userID;

            rankingTransform.Find("userID").GetComponent <Text>().text = userID;

            float score = rankingEntry.score;

            if (precision == 0)
            {
                score = Mathf.Round(score);
            }
            else
            {
                score = Mathf.Round(score * Mathf.Pow(10f, precision)) / Mathf.Pow(10f, precision);
            }
            rankingTransform.Find("score").GetComponent <Text>().text = score.ToString();

            rankingTransform.Find("background").gameObject.SetActive(ranking % 2 == 1);

            transformList.Add(rankingTransform);
        }
        private List <RankingEntry> SortRankingScore(List <RankingEntry> rankingEntryList, bool ascending)
        {
            if (!ascending)
            {
                for (int i = 0; i < rankingEntryList.Count; i++)
                {
                    for (int j = i + 1; j < rankingEntryList.Count; j++)
                    {
                        if (rankingEntryList[j].score > rankingEntryList[i].score)
                        {
                            RankingEntry cpy = rankingEntryList[i];
                            rankingEntryList[i] = rankingEntryList[j];
                            rankingEntryList[j] = cpy;
                        }
                    }
                }
            }
            else if (ascending)
            {
                for (int i = 0; i < rankingEntryList.Count; i++)
                {
                    for (int j = i + 1; j < rankingEntryList.Count; j++)
                    {
                        if (rankingEntryList[j].score < rankingEntryList[i].score)
                        {
                            RankingEntry cpy = rankingEntryList[i];
                            rankingEntryList[i] = rankingEntryList[j];
                            rankingEntryList[j] = cpy;
                        }
                    }
                }
            }

            return(rankingEntryList);
        }
        IEnumerator SimplePostRequestSendScore(string userID, string score)
        {
            RankingEntry ranking = new RankingEntry();

            ranking.userID = userID;
            ranking.score  = float.Parse(score);
            string json = JsonConvert.SerializeObject(ranking);
            //Debug.Log("data to send: " + json);

            var request = new UnityWebRequest(postURL, "POST");

            byte[] bodyRaw = Encoding.UTF8.GetBytes(json);
            request.uploadHandler   = (UploadHandler) new UploadHandlerRaw(bodyRaw);
            request.downloadHandler = (DownloadHandler) new DownloadHandlerBuffer();
            request.SetRequestHeader("Content-Type", "application/json");
            yield return(request.SendWebRequest());

            //Debug.Log("Status Code: " + request.responseCode);

            if (request.isNetworkError)
            {
                //Debug.LogError("isNetworkError " + request.error);
                message.GetComponent <Text>().color    = Color.red;
                message.GetComponent <Text>().fontSize = 25;
                message.text = request.error;
            }
            if (request.isHttpError)
            {
                //Debug.LogError("isHttpError " + request.error);
                message.GetComponent <Text>().color    = Color.red;
                message.GetComponent <Text>().fontSize = 25;
                message.text = request.error;
            }
            else
            {
                message.text = request.downloadHandler.text;
                if (message.text.Contains("Error"))
                {
                    message.GetComponent <Text>().color    = Color.red;
                    message.GetComponent <Text>().fontSize = 25;
                }
                else
                {
                    message.GetComponent <Text>().color    = Color.green;
                    message.GetComponent <Text>().fontSize = 44;
                }
            }
        }
        IEnumerator SimplePostRequestGetScore(string userID)
        {
            string   jsonStr       = PlayerPrefs.GetString("rankingTable");
            Rankings rankings      = JsonUtility.FromJson <Rankings>(jsonStr);
            string   userIDToCheck = "\"userID\":\"" + userID + "\"";

            if (!jsonStr.ToString().Contains(userIDToCheck))
            {
                message.GetComponent <Text>().color    = Color.red;
                message.GetComponent <Text>().fontSize = 44;
                message.text = "userID " + userID + " not found in Ranks";
            }
            else
            {
                var request = new UnityWebRequest(getUserIDURL + userID, "Get");
                request.downloadHandler = (DownloadHandler) new DownloadHandlerBuffer();
                request.SetRequestHeader("Content-Type", "application/json");
                yield return(request.SendWebRequest());

                //Debug.Log("Status Code: " + request.responseCode);

                if (request.isNetworkError)
                {
                    //Debug.LogError("isNetworkError " + request.error);
                    message.GetComponent <Text>().color    = Color.red;
                    message.GetComponent <Text>().fontSize = 25;
                    message.text = request.error;
                }
                if (request.isHttpError)
                {
                    //Debug.LogError("isHttpError " + request.error);
                    message.GetComponent <Text>().color    = Color.red;
                    message.GetComponent <Text>().fontSize = 25;
                    message.text = request.error;
                }
                else
                {
                    message.GetComponent <Text>().color    = Color.green;
                    message.GetComponent <Text>().fontSize = 44;

                    string       json = request.downloadHandler.text;
                    RankingEntry rank = JsonConvert.DeserializeObject <RankingEntry>(json);

                    float scoreReceived = rank.score;

                    if (UnityEditor.EditorApplication.isPlaying)
                    {
                        precision = GetInstance().GetPrecision();
                    }
                    else
                    {
                        precision = 4;
                    }

                    if (precision == 0)
                    {
                        scoreReceived = Mathf.Round(scoreReceived);
                    }
                    else
                    {
                        scoreReceived = Mathf.Round(scoreReceived * Mathf.Pow(10f, precision)) / Mathf.Pow(10f, precision);
                    }

                    message.text = "Score: " + scoreReceived.ToString();
                    userIDToGetScore.GetComponent <InputField>().text = "";
                }
            }
        }