UserChooseSceneItem.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class UserChooseSceneItem : MonoBehaviour
  6. {
  7. public Toggle tg;
  8. //场景ID
  9. public string id;
  10. public Text itemName;
  11. public Mask mask;
  12. public Camera xrCamera;
  13. public GameObject model;
  14. public Button gotoSceneBtn;
  15. private RectTransform rectTransform;
  16. // Start is called before the first frame update
  17. void Start()
  18. {
  19. xrCamera = OpenXRCamera.Instance.GetComponent<Camera>();
  20. rectTransform = GetComponent<RectTransform>();
  21. gotoSceneBtn.onClick.AddListener(() => {
  22. GameManager.Instance.isShowDownTip = true;
  23. UIManager.Instance.ShowUI(UINameConfig.LoadingPanel, typeof(LoadingPanel), (int)ELoadState.download);
  24. GameScene.Instance.gotoScenes(id);
  25. DownloadResManager.Instance.StartDownLoad();
  26. MQTTClient.Instance.SubscribeScene(id.ToString());
  27. });
  28. }
  29. // Update is called once per frame
  30. void Update()
  31. {
  32. if(mask)
  33. {
  34. //if(mask.IsRaycastLocationValid(rectTransform.position, xrCamera))
  35. //{
  36. // model.SetActive(true);
  37. //}
  38. //else
  39. //{
  40. // model.SetActive(false);
  41. //}
  42. // Debug.LogError( " MASK YC ");
  43. model.SetActive(mask.IsRaycastLocationValid(rectTransform.position, xrCamera));
  44. }
  45. }
  46. }