1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- using UnityEngine;
- using UnityEngine.Events;
- namespace NRKernal.Experimental.StreammingCast
- {
- [RequireComponent(typeof(Collider))]
- public class SettingRegionTrigger : MonoBehaviour
- {
- public UnityEvent onPointerEnter;
- public UnityEvent onPointerOut;
- private Collider m_TriggerRegion;
- private Collider m_CurrentHover;
- private Collider currentHover
- {
- get
- {
- return m_CurrentHover;
- }
- set
- {
- if (m_CurrentHover != value)
- {
- if (value == m_TriggerRegion)
- {
- OnPointerEnter();
- }
- else
- {
- OnPointerExit();
- }
- }
- m_CurrentHover = value;
- }
- }
- private Transform laserAnchor
- {
- get
- {
- return NRInput.AnchorsHelper.GetAnchor(NRInput.RaycastMode == RaycastModeEnum.Gaze ?
- ControllerAnchorEnum.GazePoseTrackerAnchor : ControllerAnchorEnum.RightLaserAnchor);
- }
- }
- void Start()
- {
- m_TriggerRegion = gameObject.GetComponent<Collider>();
- }
- void Update()
- {
- RaycastHit hitResult;
- Physics.Raycast(new Ray(laserAnchor.position, laserAnchor.forward), out hitResult, 10);
- currentHover = hitResult.collider;
- }
- public void OnPointerEnter()
- {
- onPointerEnter?.Invoke();
- }
- public void OnPointerExit()
- {
- onPointerOut?.Invoke();
- }
- }
- }
|