HomeView.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using UnityEngine.SceneManagement;
  6. public class HomeView : MonoBehaviour
  7. {
  8. [SerializeField] Text nickNameText;
  9. [SerializeField] GameObject[] genders;
  10. public static HomeView ins;
  11. void Start()
  12. {
  13. ins = this;
  14. if (GameObject.Find("Bluetooth") == null) {
  15. GameObject bluetooth = new GameObject("Bluetooth");
  16. // bluetooth.AddComponent<ShootCheck>();
  17. // bluetooth.AddComponent<BluetoothBC>();
  18. // bluetooth.AddComponent<BluetoothD>();
  19. DontDestroyOnLoad(bluetooth);
  20. }
  21. AudioMgr.init();
  22. RenderNameOrGender();
  23. }
  24. public void RenderNameOrGender() {
  25. nickNameText.text = LoginMgr.myUserInfo.nickname;
  26. genders[LoginMgr.myUserInfo.gender == "男" ? 0 : 1].SetActive(true);
  27. genders[LoginMgr.myUserInfo.gender == "男" ? 1 : 0].SetActive(false);
  28. LayoutRebuilder.ForceRebuildLayoutImmediate(nickNameText.transform.parent.GetComponent<RectTransform>());
  29. }
  30. public void GoTo(string target) {
  31. AudioMgr.ins.PlayBtn();
  32. switch (target)
  33. {
  34. case "闯关":
  35. GameObject.Instantiate(Resources.Load<GameObject>("Prefabs/Views/ChallengeReadyView"), Vector3.zero, new Quaternion());
  36. break;
  37. case "限时":
  38. GameMgr.gameMode = 2;
  39. SceneManager.LoadScene("Game", LoadSceneMode.Single);
  40. break;
  41. case "对战":
  42. // GameMgr.gameMode = 3;
  43. // SceneManager.LoadScene("Game", LoadSceneMode.Single);
  44. break;
  45. case "教程":
  46. GameObject.Instantiate(Resources.Load<GameObject>("Prefabs/Views/CourseView"), Vector3.zero, new Quaternion());
  47. break;
  48. case "设置":
  49. GameObject.Instantiate(Resources.Load<GameObject>("Prefabs/Views/SetUpView"), Vector3.zero, new Quaternion());
  50. break;
  51. case "我的":
  52. GameObject.Instantiate(Resources.Load<GameObject>("Prefabs/Views/MeView"), Vector3.zero, new Quaternion());
  53. break;
  54. case "设备":
  55. GameObject.Instantiate(Resources.Load<GameObject>("Prefabs/Views/DeviceView"), Vector3.zero, new Quaternion());
  56. break;
  57. case "商城":
  58. GameObject.Instantiate(Resources.Load<GameObject>("Prefabs/Views/ShopView"), Vector3.zero, new Quaternion());
  59. break;
  60. default:
  61. break;
  62. }
  63. }
  64. }