Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| wiki:menu_scriptss_code [2022/08/04 11:03] – [PasswordChange.cs] admin | wiki: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, | ||
| + | newItem.transform.SetParent(RankParent.transform); | ||
| + | } | ||
| + | else if (i == 1) | ||
| + | { | ||
| + | newItem = Instantiate(rankSecond, | ||
| + | newItem.transform.SetParent(RankParent.transform); | ||
| + | } | ||
| + | else if (i == 2) | ||
| + | { | ||
| + | newItem = Instantiate(rankThird, | ||
| + | newItem.transform.SetParent(RankParent.transform); | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | newItem = Instantiate(rankNorm, | ||
| + | newItem.transform.SetParent(RankParent.transform); | ||
| + | } | ||
| + | |||
| + | |||
| + | try | ||
| + | { | ||
| + | var split = item.Split(':' | ||
| + | |||
| + | newItem.transform.Find(" | ||
| + | newItem.transform.Find(" | ||
| + | |||
| + | if (i >= 3) newItem.transform.Find(" | ||
| + | } | ||
| + | catch (System.Exception) | ||
| + | { | ||
| + | Destroy(newItem); | ||
| + | } | ||
| + | |||
| + | i++; | ||
| + | } | ||
| + | |||
| + | } | ||
| + | |||
| + | } | ||
| + | |||
| + | |||
| + | </ | ||
| + | |||
| + | <file | public void ButtonOpenRankingList() > | ||
| + | When button clicked it with fetch all the player list String convert it example name: | ||
| + | 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.. | ||
| + | </ | ||