public void Initialize(SurveyQuestion inSurveyQuestion, Action <QuestionGroup> inAnsweredCallback) { m_Id = inSurveyQuestion.Id; m_QuestionText.text = inSurveyQuestion.Text; m_OnAnswered = inAnsweredCallback; if (inSurveyQuestion.Type.Equals("single-choice")) { foreach (string answer in inSurveyQuestion.Answers) { AnswerButton button = Instantiate(m_AnswerButtonPrefab, m_AnswerButtonRoot).GetComponent <AnswerButton>(); button.Initialize(answer, OnSingleChoiceSelected, null, m_AnswerToggle); } } else if (inSurveyQuestion.Type.Equals("multiple-choice")) { foreach (string answer in inSurveyQuestion.Answers) { AnswerButton button = Instantiate(m_AnswerButtonPrefab, m_AnswerButtonRoot).GetComponent <AnswerButton>(); button.Initialize(answer, OnMultipleChoiceSelected, OnMultipleChoiceDeselected, null); } } else if (inSurveyQuestion.Type.Equals("short-answer")) { ShortAnswerField field = Instantiate(m_ShortAnswerPrefab, m_AnswerButtonRoot).GetComponent <ShortAnswerField>(); field.Initialize(OnShortAnswerSubmitted); } }
private void OnShortAnswerSubmitted(ShortAnswerField inShortAnswerField) { m_SelectedAnswer = inShortAnswerField.Answer; m_OnAnswered(this); }