NewQuestionScript.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class NewQuestionScript : MonoBehaviour {
  6. public GameObject prefab;
  7. public Transform contentPanel;
  8. // Start is called before the first frame update
  9. void Start()
  10. {
  11. GetNewQuestionData();
  12. }
  13. private void GetNewQuestionData()
  14. {
  15. // if new game, create one question card to start with
  16. GameObject question = Instantiate(prefab, new Vector2(0, 0), Quaternion.identity) as GameObject;
  17. NewQuestion questionCard = question.GetComponent<NewQuestion>();
  18. PrepareQuestion(questionCard);
  19. questionCard.GetQuestion(false);
  20. Debug.Log("NEWQuestion start " + questionCard.questionText.text);
  21. questionCard.transform.SetParent(contentPanel);
  22. }
  23. public void PrepareQuestion(QuestionCard qc)
  24. {
  25. qc.questionText = GameObject.Find("NewQuestionText").GetComponent<Text>();
  26. qc.answerText = GameObject.Find("NewAnswerText").GetComponent<Text>();
  27. }
  28. // Update is called once per frame
  29. void Update()
  30. {
  31. }
  32. }