Welcome to GEMENTAR TOUR PUO V2 Development Documentation. Enjoy your stay!

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
wiki:menu_scriptss_code [2022/08/04 11:03] – [PasswordChange.cs] adminwiki:menu_scriptss_code [2022/08/04 11:04] (current) – [RankingSystem.cs] admin
Line 95: Line 95:
 ====== RankingSystem.cs ====== ====== RankingSystem.cs ======
  
 +<code CSharp | Full Script>
 +using Sirenix.OdinInspector;
 +using System.Collections;
 +using System.Collections.Generic;
 +using TMPro;
 +using UnityEngine;
 +
 +public class RankingSystem : MonoBehaviour
 +{
 +    public GameObject RankParent;
 +    public GameObject rankFirst;
 +    public GameObject rankSecond;
 +    public GameObject rankThird;
 +    public GameObject rankNorm;
 +    public GameObject scoreUI;
 +
 +    public hidden;
 +
 +    bool toggleRankingList = true;
 +
 +    public void ButtonOpenRankingList()
 +    {
 +        scoreUI.SetActive(true);
 +
 +        if (toggleRankingList == false) return;
 +        toggleRankingList = false;
 +        var playerlist = hidden
 +
 +        int i = 0;
 +        foreach (var item in playerlist)
 +        {
 +            GameObject newItem;
 +            if (i == 0)
 +            {
 +                newItem = Instantiate(rankFirst, this.transform);
 +                newItem.transform.SetParent(RankParent.transform);
 +            }
 +            else if (i == 1)
 +            {
 +                newItem = Instantiate(rankSecond, this.transform);
 +                newItem.transform.SetParent(RankParent.transform);
 +            }
 +            else if (i == 2)
 +            {
 +                newItem = Instantiate(rankThird, this.transform);
 +                newItem.transform.SetParent(RankParent.transform);
 +            }
 +            else
 +            {
 +                newItem = Instantiate(rankNorm, this.transform);
 +                newItem.transform.SetParent(RankParent.transform);
 +            }
 +
 +
 +            try
 +            {
 +            var split = item.Split(':');
 +
 +            newItem.transform.Find("Text_Score").gameObject.GetComponent<TextMeshProUGUI>().SetText(split[1], 3.5f);
 +            newItem.transform.Find("Text_NickName").gameObject.GetComponent<TextMeshProUGUI>().SetText(split[0], 3.5f);
 +
 +            if (i >= 3) newItem.transform.Find("Text_4").gameObject.GetComponent<TextMeshProUGUI>().SetText((i + 1).ToString(), 3.5f);
 +            }
 +            catch (System.Exception)
 +            {
 +                Destroy(newItem);
 +            }
 +
 +            i++;
 +        }
 +
 +    }
 +
 +}
 +
 +
 +</code>
 +
 +<file | public void ButtonOpenRankingList() > 
 +When button clicked it with fetch all the player list String convert it example name:score:email and it will split it by ":"
 +iterate through all the users
 +instantiate object for ever iteration and assign it
 +due to the list already sort it self by player score in sQL query so we will not sort it here all done in server side..
 +</file>

QR Code
QR Code wiki:menu_scriptss_code (generated for current page)
Hello World!
DokuWiki with monobook... rules!