コード例 #1
0
        private void OnMaxPlayersInputChanged(string value)
        {
            uint maxPlayers = 0;

            if (!uint.TryParse(value, out maxPlayers))
            {
                MaxPlayers = 2;
                maxPlayersInputField.text = "2";
                return;
            }

            if (maxPlayers > MaxPlayersAllowed)
            {
                MaxPlayers = MaxPlayersAllowed;
                maxPlayersInputField.text = MaxPlayersAllowed.ToString();
                return;
            }

            if (maxPlayers < MinPlayers)
            {
                MaxPlayers = MinPlayers;
                maxPlayersInputField.text = MinPlayers.ToString();
                return;
            }

            MaxPlayers = maxPlayers;
        }
コード例 #2
0
        private void OnMinPlayersInputChanged(string value)
        {
            uint minPlayers = 0;

            if (!uint.TryParse(value, out minPlayers))
            {
                MinPlayers = 2;
                minPlayersInputField.text = "2";
                return;
            }

            if (minPlayers < 2)
            {
                MinPlayers = 2;
                minPlayersInputField.text = "2";
                return;
            }

            if (MaxPlayers < minPlayers)
            {
                MaxPlayers = (uint)Mathf.Clamp(minPlayers, 2, MaxPlayersAllowed);
                maxPlayersInputField.text = MaxPlayers.ToString();
            }

            if (minPlayers > MaxPlayersAllowed)
            {
                MinPlayers = MaxPlayersAllowed;
                minPlayersInputField.text = MaxPlayersAllowed.ToString();
                return;
            }

            MinPlayers = minPlayers;
        }