示例#1
0
    public void OnButtonClick()
    {
        currentQuestion = inputfield.text;

        if (string.IsNullOrEmpty(currentQuestion) || currentQuestion.LastIndexOf('?') == -1)
        {
            ballText.text = "";
            ShowError("Not a valid question!");
        }
        else
        {
            QA currentInput = _answers.CheckIfAnswered(currentQuestion, historyQA);

            if (currentInput == null)
            {
                currentInput = new QA(currentQuestion, _answers.GetAnswer(currentQuestion));
                historyQA.Add(currentInput);

                ballAnimator.SetTrigger("StartAnimation");
                ballText.text = "";

                StartCoroutine(ShowAnswer(currentInput, ballAnimationTime));

                inputfield.interactable = false;
            }
            else
            {
                ballText.text = "";
                ShowError("Already asked!");
            }
        }

        inputfield.text = "";
        inputfield.Select();
        inputfield.ActivateInputField();
    }