Exemplo n.º 1
0
    // Start is called before the first frame update
    void Start()
    {
        worldname  = PlayerPrefs.GetString("WorldName");
        WorldNames = worldname.Split(',');

        WorldDropdown.ClearOptions();
        SortDropdown.ClearOptions();
        OrderDropdown.ClearOptions();

        List <string> AllWorldNames = new List <string>(WorldNames);
        List <string> Sort          = new List <string>()
        {
            "Score", "Time"
        };
        List <string> Order = new List <string>()
        {
            "Descending", "Ascending"
        };

        WorldDropdown.AddOptions(AllWorldNames);
        SortDropdown.AddOptions(Sort);
        OrderDropdown.AddOptions(Order);
    }
    public void OnClick()
    {
        //changes sort mode.
        sortDropdown = GameObject.Find("Sort").GetComponent <SortDropdown>();
        GameManager gameManager = GameObject.Find("GameManager").GetComponent <GameManager>();

        gameManager.sortMode = (SortDropdown.SortMode)sortDropdown.selectedItemIndex;

        //changes order.
        if (gameManager.recentClick == null || gameObject != gameManager.recentClick)
        {
            gameManager.recentClick = gameObject;
        }
        else
        {
            if (SortDropdown.isAscendingOrder)
            {
                SortDropdown.isAscendingOrder = false;
            }
            else
            {
                SortDropdown.isAscendingOrder = true;
            }

            sortDropdown.selectedImage.rectTransform.Rotate(new Vector3(0, 0, 180));
        }

        //lastly refreshes.
        if (GameManager.isModeNow)
        {
            gameManager.RefreshPlayerList(gameManager.mode, gameManager.sortMode, GameManager.currentStartingMemberFilter);
        }
        else
        {
            gameManager.RefreshPlayerList(GameManager.currentMetaPosition, gameManager.sortMode, GameManager.currentStartingMemberFilter);
        }
    }