Exemplo n.º 1
0
        private void OnStateChangedHandler(INPUT_FIELD_STATES newState)
        {
            bool hasError = newState != INPUT_FIELD_STATES.NONE;

            gameObject.SetActive(hasError);

            if (hasError)
            {
                ShowErrorTextByType(newState);
            }
        }
Exemplo n.º 2
0
        private void OnValueChangedHandler(string newValue)
        {
            INPUT_FIELD_STATES newState = InputState.Value;

            newState = CheckForOverflow(newValue, newState);
            newState = CheckForInvalid(newValue, newState);

            if (newState != InputState.Value)
            {
                InputState.Value = newState;
            }
        }
Exemplo n.º 3
0
        private INPUT_FIELD_STATES CheckForOverflow(string newValue, INPUT_FIELD_STATES state)
        {
            if (newValue.Length > maxLength)
            {
                state |= INPUT_FIELD_STATES.OVERFLOW;
            }
            else
            {
                state &= ~INPUT_FIELD_STATES.OVERFLOW;
            }

            return(state);
        }
Exemplo n.º 4
0
        private INPUT_FIELD_STATES CheckForInvalid(string newValue, INPUT_FIELD_STATES state)
        {
            bool hasInvalid = Regex.IsMatch(newValue, regexPattern);

            if (hasInvalid)
            {
                state |= INPUT_FIELD_STATES.INVALID;
            }
            else
            {
                state &= ~INPUT_FIELD_STATES.INVALID;
            }

            return(state);
        }
Exemplo n.º 5
0
        private void ShowErrorTextByType(INPUT_FIELD_STATES state)
        {
            StringBuilder builder = new StringBuilder();

            if ((state & INPUT_FIELD_STATES.OVERFLOW) == INPUT_FIELD_STATES.OVERFLOW)
            {
                builder.AppendLine(overflowTextError);
            }

            if ((state & INPUT_FIELD_STATES.INVALID) == INPUT_FIELD_STATES.INVALID)
            {
                builder.AppendLine(invalidTextError);
            }

            errorText.text = builder.ToString();
        }
Exemplo n.º 6
0
 private void OnStateChangedHandler(INPUT_FIELD_STATES state)
 {
     btn.interactable = state == INPUT_FIELD_STATES.NONE;
 }