NewQuestionScript.cs 841 B

1234567891011121314151617181920212223242526
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using UnityEngine.EventSystems;
  6. public class NewQuestionScript : MonoBehaviour {
  7. public GameObject prefab;
  8. public Transform contentPanel;
  9. QuestionCard questionCard;
  10. // Start is called before the first frame update
  11. void Start() {
  12. GetNewQuestionData();
  13. }
  14. private void GetNewQuestionData() {
  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. questionCard = question.GetComponent<NewQuestion>();
  18. questionCard.PrepareQuestion("NewQuestionText", "NewAnswerText");
  19. questionCard.GetQuestion(false);
  20. questionCard.transform.SetParent(contentPanel);
  21. }
  22. }