UserChooseScene.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. public class UserChooseScene : MonoBehaviour
  7. {
  8. public GameObject cs;
  9. public GameObject st;
  10. public UserChooseSceneItem item;
  11. List<UserChooseSceneItem> list = new List<UserChooseSceneItem>();
  12. // Start is called before the first frame update
  13. void Start()
  14. {
  15. initList();
  16. }
  17. public RectTransform scrollview;
  18. public void initList()
  19. {
  20. Debug.Log("当前场景===》" + UserSceneManager.Instance.SceneList.Count) ;
  21. foreach(var i in UserSceneManager.Instance.SceneList.Values)
  22. {
  23. UserChooseSceneItem go = GameObject.Instantiate(item, item.transform.parent);
  24. go.gameObject.SetActive(true);
  25. go.itemName.text = i.name;
  26. go.id = i.id;
  27. list.Add(go);
  28. }
  29. switch (UserSceneManager.Instance.SceneList.Count)
  30. {
  31. case 1:
  32. scrollview.sizeDelta = new Vector2(200, 291);
  33. break;
  34. case 2:
  35. scrollview.sizeDelta = new Vector2(500, 291);
  36. break;
  37. }
  38. list[0].tg.isOn = true;
  39. }
  40. public void gotoScene()
  41. {
  42. GameManager.Instance.isShowDownTip = true;
  43. UIManager.Instance.ShowUI(UINameConfig.LoadingPanel, typeof(LoadingPanel), (int)ELoadState.download);
  44. cs.SetActive(false);
  45. for (int i = 0; i < list.Count; i++)
  46. {
  47. if(list[i].tg.isOn)
  48. {
  49. GameScene.Instance.gotoScenes(list[i].id);
  50. break;
  51. }
  52. }
  53. DownloadResManager.Instance.StartDownLoad();
  54. }
  55. public void CloseCS()
  56. {
  57. cs.SetActive(false);
  58. }
  59. }