private void CheckProceed()
    {
        if (m_Gamepads == null || m_Phones == null || m_TriggerProceed == null)
        {
            return;
        }

        bool confirm = false;

        // Check gamepads

        for (int gamepadIndex = 0; gamepadIndex < m_Gamepads.Count; ++gamepadIndex)
        {
            tnUIGamepad gamepad = m_Gamepads[gamepadIndex];
            if (gamepad != null)
            {
                if (gamepad.deviceState == DeviceState.Left || gamepad.deviceState == DeviceState.Right)
                {
                    confirm |= gamepad.GetProceedButton();
                }
            }
        }

        // Check phones

        for (int phoneIndex = 0; phoneIndex < m_Phones.Count; ++phoneIndex)
        {
            tnUIPhone phone = m_Phones[phoneIndex];
            if (phone != null)
            {
                if (phone.deviceState == DeviceState.Left || phone.deviceState == DeviceState.Right)
                {
                    confirm |= phone.GetProceedButton();
                }
            }
        }

        if (confirm)
        {
            m_TriggerProceed.Invoke();
        }
    }
    private void CheckCancel()
    {
        if (m_Gamepads == null || m_Phones == null || m_TriggerCancel == null)
        {
            return;
        }

        bool cancel = false;

        // Check gamepads

        for (int gamepadIndex = 0; gamepadIndex < m_Gamepads.Count; ++gamepadIndex)
        {
            tnUIGamepad gamepad = m_Gamepads[gamepadIndex];
            if (gamepad != null)
            {
                cancel |= gamepad.GetCancelButton();
            }
        }

        // Check phones

        for (int phoneIndex = 0; phoneIndex < m_Phones.Count; ++phoneIndex)
        {
            tnUIPhone phone = m_Phones[phoneIndex];
            if (phone != null)
            {
                cancel |= phone.GetCancelButton();
            }
        }

        if (cancel)
        {
            m_TriggerCancel.Invoke();
        }
    }
    public override void OnExit()
    {
        m_HasFocus = false;

        for (int phoneIndex = 0; phoneIndex < m_Phones.Count; ++phoneIndex)
        {
            tnUIPhone phone = m_Phones[phoneIndex];
            if (phone != null)
            {
                phone.hasFocus = false;
            }
        }

        for (int gamepadIndex = 0; gamepadIndex < m_Gamepads.Count; ++gamepadIndex)
        {
            tnUIGamepad gamepad = m_Gamepads[gamepadIndex];
            if (gamepad != null)
            {
                gamepad.hasFocus = false;
            }
        }

        base.OnExit();
    }
    private void SpawnPhones()
    {
        if (m_UIPhonePrefab == null)
        {
            return;
        }

        if (m_ControllersGrid == null)
        {
            return;
        }

        if (m_ControllersRoot == null)
        {
            return;
        }

        List <int> playersKeys = tnGameData.GetPlayersKeysMain();

        if (playersKeys == null)
        {
            return;
        }

        int playersCount = WiFiInputSystem.playersCountMain;
        int max          = Mathf.Min(playersCount, playersKeys.Count);

        for (int index = 0; index < max; ++index)
        {
            ControllerAnchor anchor = m_ControllersGrid.GetAnchorByIndex(index + m_Gamepads.Count);
            if (anchor != null)
            {
                int playerIndex = index + m_Gamepads.Count;

                if (playerIndex >= playersKeys.Count)
                {
                    continue;
                }

                int          playerId   = playersKeys[playerIndex];
                tnPlayerData playerData = tnGameData.GetPlayerDataMain(playerId);
                if (playerData != null)
                {
                    tnUIPhone phone = GameObject.Instantiate <tnUIPhone>(m_UIPhonePrefab);
                    phone.transform.SetParent(m_ControllersRoot, false);

                    phone.SetPlayerId(playerId);
                    phone.SetPlayerName(playerData.wifiPlayerInputName);

                    phone.SetDefaultAnchor(anchor);

                    phone.gameObject.name = playerData.name + "_Phone";
                    Color color = playerData.color;
                    phone.SetColor(color, true);

                    phone.SetTeamsManagers(m_TeamA, m_TeamB);

                    phone.hasFocus = false;

                    m_Phones.Add(phone);
                }
            }
        }
    }