public static TInputDevice GetDevice <TInputDevice>() where TInputDevice : InputDevice, new()
        {
            if (s_Instance == null)
            {
                var go = new GameObject("VirtualDeviceManager");
                go.hideFlags = HideFlags.HideInHierarchy;
                s_Instance   = go.AddComponent <VirtualDeviceManager>();
                DontDestroyOnLoad(go);
            }

            return(s_Instance.GetDeviceInternal <TInputDevice>());
        }
        public void OnPointerDown(PointerEventData data)
        {
            Gamepad       gamepad = VirtualDeviceManager.GetDevice <Gamepad>();
            ButtonControl control;

            switch (m_ButtonControl)
            {
            case ButtonOption.Action1: control = gamepad.action1; break;

            case ButtonOption.Action2: control = gamepad.action2; break;

            case ButtonOption.Action3: control = gamepad.action3; break;

            case ButtonOption.Action4: control = gamepad.action4; break;

            default: return;
            }
            VirtualDeviceManager.SendValueToControl(control, 1);
        }
Exemplo n.º 3
0
        void UpdateVirtualAxes(Vector3 delta)
        {
            Gamepad gamepad = VirtualDeviceManager.GetDevice <Gamepad>();

            if (m_UseX)
            {
                ButtonControl control;
                control = (m_StickChoice == StickOption.LeftStick ? gamepad.leftStickLeft : gamepad.rightStickLeft);
                VirtualDeviceManager.SendValueToControl(control, Mathf.Max(0, -delta.x));
                control = (m_StickChoice == StickOption.LeftStick ? gamepad.leftStickRight : gamepad.rightStickRight);
                VirtualDeviceManager.SendValueToControl(control, Mathf.Max(0, delta.x));
            }

            if (m_UseY)
            {
                ButtonControl control;
                control = (m_StickChoice == StickOption.LeftStick ? gamepad.leftStickDown : gamepad.rightStickDown);
                VirtualDeviceManager.SendValueToControl(control, Mathf.Max(0, -delta.y));
                control = (m_StickChoice == StickOption.LeftStick ? gamepad.leftStickUp : gamepad.rightStickUp);
                VirtualDeviceManager.SendValueToControl(control, Mathf.Max(0, delta.y));
            }
        }