using UnityEngine; using UnityEngine.Rendering; using UnityEngine.XR.Interaction.Toolkit; using BigSpace.Logic; using BigSpace.XRCore.Event; public class SetHandRay : MonoBehaviour { public GameObject LeftRya; public GameObject RigthRay; XRRayInteractor xRRayInteractor_Left; LineRenderer lineRenderer_Left; XRInteractorLineVisual xRInteractorLineVisual_Left; SortingGroup sortingGroup_Left; XRRayInteractor xRRayInteractor_Right; LineRenderer lineRenderer_Right; XRInteractorLineVisual xRInteractorLineVisual_Right; SortingGroup sortingGroup_Right; // Start is called before the first frame update void Start() { xRRayInteractor_Left = LeftRya.GetComponent(); lineRenderer_Left = LeftRya.GetComponent(); xRInteractorLineVisual_Left = LeftRya.GetComponent(); sortingGroup_Left = LeftRya.GetComponent(); xRRayInteractor_Right = RigthRay.GetComponent(); lineRenderer_Right = RigthRay.GetComponent(); xRInteractorLineVisual_Right = RigthRay.GetComponent(); sortingGroup_Right = RigthRay.GetComponent(); GlobalEventMgr.Listen(GameEvent.EventSetHandRay, GameDataManage_EventSetHandRay); } void GameDataManage_EventSetHandRay(bool isShow) { if (isShow) { ShowHandRay(); } else { HideHandRay(); } } void HideHandRay() { xRRayInteractor_Left.enabled = false; lineRenderer_Left.enabled = false; xRInteractorLineVisual_Left.enabled = false; sortingGroup_Left.enabled = false; xRRayInteractor_Right.enabled = false; lineRenderer_Right.enabled = false; xRInteractorLineVisual_Right.enabled = false; sortingGroup_Right.enabled = false; } void ShowHandRay() { xRRayInteractor_Left.enabled = true; lineRenderer_Left.enabled = true; xRInteractorLineVisual_Left.enabled = true; sortingGroup_Left.enabled = true; xRRayInteractor_Right.enabled = true; lineRenderer_Right.enabled = true; xRInteractorLineVisual_Right.enabled = true; sortingGroup_Right.enabled = true; } }