SChooseItem.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using System;
  2. using UnityEngine;
  3. using UnityEngine.EventSystems;
  4. using UnityEngine.UI;
  5. public class SChooseItem : MonoBehaviour,IPointerClickHandler
  6. {
  7. public Text tname;
  8. /// <summary>
  9. /// 当选择场景时触发事件
  10. /// </summary>
  11. public event Action<SceneValue, bool> OnSelectScene;
  12. private SceneValue m_SceneData;
  13. public SceneValue SceneData
  14. {
  15. get { return m_SceneData; }
  16. set {
  17. Debug.Log("valuevaluevalue==>");
  18. Debug.Log("valuevaluevalue==>"+value.name);
  19. m_SceneData = value; }
  20. }
  21. public GameObject sceneChoose_go;
  22. private SceneChoose mSceneChoose;
  23. public void OnPointerClick(PointerEventData eventData)
  24. {
  25. Debug.Log("valuevaluevalue==>");
  26. Debug.Log("valuevaluevalue==>" + m_SceneData.name);
  27. mSceneChoose = sceneChoose_go.GetComponent<SceneChoose>();
  28. OnSelectScene?.Invoke(m_SceneData, true);
  29. mSceneChoose.OnClickOKBtn(m_SceneData);
  30. }
  31. public Camera xrCamera;
  32. public void init(SceneValue sv)
  33. {
  34. xrCamera = OpenXRCamera.Instance.GetComponent<Camera>();
  35. rectTransform = GetComponent<RectTransform>();
  36. SceneData = sv;
  37. tname.text = sv.name;
  38. }
  39. public Mask mask;
  40. public GameObject model;
  41. private RectTransform rectTransform;
  42. // Update is called once per frame
  43. void Update()
  44. {
  45. if (mask)
  46. {
  47. //if(mask.IsRaycastLocationValid(rectTransform.position, xrCamera))
  48. //{
  49. // model.SetActive(true);
  50. //}
  51. //else
  52. //{
  53. // model.SetActive(false);
  54. //}
  55. // Debug.LogError( " MASK YC ");
  56. model.SetActive(mask.IsRaycastLocationValid(rectTransform.position, xrCamera));
  57. }
  58. }
  59. }