GongDanMainManager.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using LitJson;
  4. using UnityEngine;
  5. public class GongDanMainManager : MonoBehaviour
  6. {
  7. public ChuLiItemManager citem;
  8. public List<ChuLiItemManager> listitem=new List<ChuLiItemManager>();
  9. JsonData data;
  10. int indexex;
  11. public void initData(int i)
  12. {
  13. indexex=i;
  14. switch (indexex)
  15. {
  16. case 0:
  17. data = WindowMainManager.instance.DyData;
  18. break;
  19. case 1:
  20. data = WindowMainManager.instance.wwcData;
  21. break;
  22. case 2:
  23. data = WindowMainManager.instance.ywcData;
  24. break;
  25. }
  26. for (int j = 0;j<listitem.Count;j++)
  27. {
  28. Destroy(listitem[j].gameObject);
  29. }
  30. listitem.Clear();
  31. for (int j = 0;j< data["list"].Count;j++)
  32. {
  33. ChuLiItemManager item = GameObject.Instantiate(citem,citem.transform.parent);
  34. item.init( data["list"][j]);
  35. item.gameObject.SetActive(true);
  36. listitem.Add(item);
  37. }
  38. }
  39. public void init()
  40. {
  41. for (int j = 0;j<listitem.Count;j++)
  42. {
  43. Destroy(listitem[j].gameObject);
  44. }
  45. listitem.Clear();
  46. }
  47. void OnEnable()
  48. {
  49. Invoke("initdata",0.2f);
  50. }
  51. void initdata()
  52. {
  53. GongDanWindowManager.Instance.ttison();
  54. }
  55. }