ScrollViewScript.cs 951 B

12345678910111213141516171819202122232425262728293031323334
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class ScrollViewScript : MonoBehaviour
  5. {
  6. public GameObject prefab;
  7. public Transform contentPanel;
  8. // Start is called before the first frame update
  9. void Start()
  10. {
  11. SetGiventQuestion();
  12. }
  13. public void SetGiventQuestion()
  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. QuestionCard questionCard = question.GetComponent<QuestionCard>();
  18. questionCard.PrepareQuestion();
  19. questionCard.GetQuestion(true);
  20. Debug.Log("ScrollView Question start " + questionCard.questionText.text + " questionString " + questionCard.questionString);
  21. questionCard.transform.SetParent(contentPanel);
  22. }
  23. // Update is called once per frame
  24. void Update()
  25. {
  26. }
  27. }