summaryrefslogtreecommitdiff
path: root/Assets/Samples/OpenXR Plugin/1.14.3/Controller/Scripts/ActionToVisibilityISX.cs
blob: ab8d7aed2efbfbefae3459e2eb2e82a1b4aee01f (plain)
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
32
33
34
35
36
37
38
39
40
41
42
using UnityEngine.InputSystem;

namespace UnityEngine.XR.OpenXR.Samples.ControllerSample
{
    public class ActionToVisibilityISX : MonoBehaviour
    {
        [SerializeField]
        InputActionProperty m_ActionReference;
        public InputActionProperty actionReference { get => m_ActionReference; set => m_ActionReference = value; }


        [SerializeField]
        GameObject m_TargetGameobject = null;
        public GameObject targetGameObject { get => m_TargetGameobject; set => m_TargetGameobject = value; }

        private void Start()
        {
            if (m_ActionReference != null && m_ActionReference.action != null)
                m_ActionReference.action.Enable();
        }

        void Update()
        {
            if (m_TargetGameobject == null)
                return;

            if (m_ActionReference != null
                && m_ActionReference.action != null
                && m_ActionReference.action.controls.Count > 0
                && m_ActionReference.action.enabled == true)
            {
                m_TargetGameobject.SetActive(true);
                return;
            }
            else
            {
                // No Matching devices:
                m_TargetGameobject.SetActive(false);
            }
        }
    }
}