Skip to content

Instantly share code, notes, and snippets.

@tetya
Last active April 27, 2016 11:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tetya/1a8d1b1f4f616d7a2c4ce711f30aef17 to your computer and use it in GitHub Desktop.
Save tetya/1a8d1b1f4f616d7a2c4ce711f30aef17 to your computer and use it in GitHub Desktop.
void AddButton(QuestionDB.QuestionData DataRow, int answerID, int i){
//子オブジェクトとして追加
RectTransform item = GameObject.Instantiate(buttonPrefab) as RectTransform;
//ボタンの表示を割り当てる
item.GetComponentInChildren<Text> ().text = DataRow.answer;
//コンテンツの子オブジェクトにする
item.SetParent(transform, false);
//ボタンに呼び出すメソッドを割り当てる
if(DataRow.id == answerID){
item.GetComponent<Button> ().onClick.AddListener(Correct);
}else{
item.GetComponent<Button> ().onClick.AddListener(Inorrect);
}
//時間差表示演出
item.GetComponent<AnswerItem> ().Show(0.1f * i);
}
void Correct(){
sManager.Correct ();
}
void Inorrect(){
sManager.Incorrect ();
}
void AddInputField(QuestionDB.QuestionData DataRow, int i){
//子オブジェクトとして追加
RectTransform item = GameObject.Instantiate(inputFieldPrefab) as RectTransform;
//コンテンツの子オブジェクトにする
item.SetParent(transform, false);
InputField input = item.GetComponent<InputField> ();
input.onEndEdit.AddListener (delegate{CheckTextBox(input);});
//時間差表示演出
item.GetComponent<AnswerItem> ().Show(0.1f * i);
}
void CheckTextBox(InputField input){
sManager.CheckTextBox (input.text);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment