Esempio n. 1
0
    private void FixedUpdate()
    {
        if (Gamepad.current != null)
        {
            currentGamepad = Gamepad.current;
            if (currentGamepad.selectButton.wasPressedThisFrame)
            {
                m_GameFlowManager.OnJoin();
            }
        }
        var allGamepads = Gamepad.all;

        Debug.Log(allGamepads.Count);



        currentKeyboard             = Keyboard.current;
        InputSystem.onDeviceChange +=
            (device, change) =>
        {
            switch (change)
            {
            case InputDeviceChange.Added:
                // New Device
                if (device != null)
                {
                    Debug.LogWarning("New device added: " + device);
                    InputSystem.AddDevice(device);
                    for (int i = 0; i < Gamepad.all.Count; ++i)
                    {
                        if (device == Gamepad.all.ToArray()[i])
                        {
                            currentGamepad = Gamepad.all.ToArray()[i];
                        }
                    }
                    //If on touchscreen and gamepad is connected
                    //Disable touch controls and use gamepad
                    //Do vice versa
                }

                break;

            case InputDeviceChange.Disconnected:
                // Device got unplugged
                Debug.LogWarning("Device is disconnected: " + device);
                //InputSystem.Dis
                break;

            case InputDeviceChange.Reconnected:
                // Plugged back in
                Debug.LogWarning("Device reconnected: " + device);
                break;

            case InputDeviceChange.Removed:
                // Remove from Input System entirely; by default, devices stay in the system once discovered
                //Debug.LogWarning("Device removed: " + device);
                InputSystem.RemoveDevice(device);

                break;

            default:
                // See InputDeviceChange reference for other event types.
                break;
            }
        };

        if (!m_GameFlowManager)
        {
            m_GameFlowManager = FindObjectOfType <GameFlowManager>();
        }
    }