MainCenterManager.cs 837 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class MainCenterManager : MonoBehaviour
  5. {
  6. public static MainCenterManager Instance;
  7. public List<GameObject> list;
  8. private void Awake()
  9. {
  10. Instance = this;
  11. list = new List<GameObject>();
  12. int ct = this.transform.childCount;
  13. for (int i = 0; i < ct; i++)
  14. {
  15. list.Add(this.transform.GetChild(i).gameObject);
  16. }
  17. }
  18. private void OnEnable() {
  19. showMain();
  20. }
  21. public void show()
  22. {
  23. for (int i = 0; i < list.Count; i++)
  24. {
  25. if(list[i].activeSelf)
  26. list[i].SetActive(false);
  27. }
  28. }
  29. public void showMain()
  30. {
  31. MainCenterManager.Instance.show();
  32. list[0].SetActive(true);
  33. }
  34. }