| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using UnityEngine.SceneManagement;
- public class HomeView : MonoBehaviour
- {
- [SerializeField] Text nickNameText;
- [SerializeField] GameObject[] genders;
- public static HomeView ins;
- void Start()
- {
- ins = this;
- if (GameObject.Find("Bluetooth") == null) {
- GameObject bluetooth = new GameObject("Bluetooth");
- // bluetooth.AddComponent<ShootCheck>();
- // bluetooth.AddComponent<BluetoothBC>();
- // bluetooth.AddComponent<BluetoothD>();
- DontDestroyOnLoad(bluetooth);
- }
- AudioMgr.init();
- RenderNameOrGender();
- }
- public void RenderNameOrGender() {
- nickNameText.text = LoginMgr.myUserInfo.nickname;
- genders[LoginMgr.myUserInfo.gender == "男" ? 0 : 1].SetActive(true);
- genders[LoginMgr.myUserInfo.gender == "男" ? 1 : 0].SetActive(false);
- LayoutRebuilder.ForceRebuildLayoutImmediate(nickNameText.transform.parent.GetComponent<RectTransform>());
- }
- public void GoTo(string target) {
- AudioMgr.ins.PlayBtn();
- switch (target)
- {
- case "闯关":
- GameObject.Instantiate(Resources.Load<GameObject>("Prefabs/Views/ChallengeReadyView"), Vector3.zero, new Quaternion());
- break;
- case "限时":
- GameMgr.gameMode = 2;
- SceneManager.LoadScene("Game", LoadSceneMode.Single);
- break;
- case "对战":
- // GameMgr.gameMode = 3;
- // SceneManager.LoadScene("Game", LoadSceneMode.Single);
- break;
- case "教程":
- GameObject.Instantiate(Resources.Load<GameObject>("Prefabs/Views/CourseView"), Vector3.zero, new Quaternion());
- break;
- case "设置":
- GameObject.Instantiate(Resources.Load<GameObject>("Prefabs/Views/SetUpView"), Vector3.zero, new Quaternion());
- break;
- case "我的":
- GameObject.Instantiate(Resources.Load<GameObject>("Prefabs/Views/MeView"), Vector3.zero, new Quaternion());
- break;
- case "设备":
- GameObject.Instantiate(Resources.Load<GameObject>("Prefabs/Views/DeviceView"), Vector3.zero, new Quaternion());
- break;
- case "商城":
- GameObject.Instantiate(Resources.Load<GameObject>("Prefabs/Views/ShopView"), Vector3.zero, new Quaternion());
- break;
- default:
- break;
- }
- }
- }
|