UpData.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. public class UpData : MonoBehaviour
  6. {
  7. public GameObject canvas;
  8. public ShowPrefab showPrefab;
  9. public Transform showParent;
  10. private List<GameObject> createGameObjects;
  11. private ArrayData arrayData;
  12. void Start()
  13. {
  14. }
  15. // Update is called once per frame
  16. void Update()
  17. {
  18. }
  19. public void Init(List<QuestionData> saveData)
  20. {
  21. if (createGameObjects != null)
  22. {
  23. foreach (GameObject item in createGameObjects)
  24. {
  25. Destroy(item);
  26. }
  27. }
  28. canvas.SetActive(true);
  29. gameObject.SetActive(true);
  30. createGameObjects = new List<GameObject>();
  31. arrayData = new ArrayData();
  32. arrayData.wrongCount = 0;
  33. arrayData.correctCount = 0;
  34. arrayData.wrongQuestions = new List<WrongQuestionsItem>();
  35. for (int i = 0; i < saveData.Count; i++)
  36. {
  37. ShowPrefab obj = Instantiate(showPrefab, showParent);
  38. obj.text.text = "ÌâºÅ" + i;
  39. createGameObjects.Add(showPrefab.gameObject);
  40. if (saveData[i].isRight)
  41. {
  42. obj.falseObject.SetActive(false);
  43. obj.trueObject.SetActive(true);
  44. arrayData.correctCount += 1;
  45. }
  46. else
  47. {
  48. obj.falseObject.SetActive(true);
  49. obj.trueObject.SetActive(false);
  50. WrongQuestionsItem item = new WrongQuestionsItem();
  51. item.questionId = i.ToString();
  52. item.userWrongOption = saveData[i].selectIndex;
  53. arrayData.wrongQuestions.Add(item);
  54. arrayData.wrongCount += 1;
  55. }
  56. }
  57. }
  58. public void StartUpDate()
  59. {
  60. Login.Instance.SendList(arrayData);
  61. }
  62. }
粤ICP备19079148号