miepzerino
2025-03-30 d2ab30e7a69bfe7efda63ae75812207377917bd3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#if UNITY_XRI
 
using UnityEngine;
using UnityEngine.XR.Interaction.Toolkit;
 
namespace Flexalon
{
    public class FlexalonXRInputProvider : MonoBehaviour, InputProvider
    {
        public InputMode InputMode => InputMode.External;
        public bool Active => _selected;
        public Ray Ray => default;
        public Vector3 UIPointer => default;
        public GameObject ExternalFocusedObject => (_hovered || _selected) ? gameObject : null;
 
        private XRBaseInteractable _interactable;
        private bool _hovered => _interactable?.isHovered ?? false;
        private bool _selected => _interactable?.isSelected ?? false;
 
        public void Awake()
        {
            _interactable = GetComponent<XRBaseInteractable>();
            if (_interactable == null)
            {
                Debug.LogWarning("FlexalonXRInputProvider should be placed next to an XR Interactable component.");
            }
        }
    }
}
 
#endif