Ejemplo n.º 1
0
    /// <summary>
    /// Change la sélection du bouton [debug]
    /// </summary>
    public void SwitchButtonDebug()
    {
        if (idFormerButton == 12)
        {
            idCurrentButton = 1;
        }
        else
        {
            idCurrentButton = idFormerButton + 1;
        }
        // Enfin, selon l'id du bouton, on fait l'échange de sélection entre les boutons
        if (idFormerButton != idCurrentButton)
        {
            selectedButton = boutons[idCurrentButton - 1];
            formerButton   = boutons[idFormerButton - 1];

            selectedButton.Select();
            formerButton.Deselect();

            idFormerButton = idCurrentButton;
        }
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Change le bouton sélectionné en fonction de l'angle
    /// </summary>
    /// <param name="angle"></param>
    public void SwitchButton(float angle)
    {
        // Il y a 12 boutons => répartition en 12 zones
        // De manière empirique : on a regardé l'angle calculé sur l'inspecteur en runtime pour savoir quel id correspond à quel angle
        if (menuPosition[0] >= 0)
        {
            if (0.0f < angle && angle <= Mathf.PI / 12)
            {
                idCurrentButton = 10;
            }

            if (Mathf.PI / 12 < angle && angle <= 3 * Mathf.PI / 12)
            {
                idCurrentButton = 9;
            }

            if (3 * Mathf.PI / 12 < angle && angle <= 5 * Mathf.PI / 12)
            {
                idCurrentButton = 8;
            }

            if ((5 * Mathf.PI / 12 < angle && angle <= Mathf.PI / 2) || (-Mathf.PI / 2 <= angle && angle <= -5 * Mathf.PI / 12))
            {
                idCurrentButton = 7;
            }

            if (-5 * Mathf.PI / 12 < angle && angle <= -3 * Mathf.PI / 12)
            {
                idCurrentButton = 6;
            }

            if (-3 * Mathf.PI / 12 < angle && angle <= -Mathf.PI / 12)
            {
                idCurrentButton = 5;
            }

            if (-Mathf.PI / 12 < angle && angle <= 0.0)
            {
                idCurrentButton = 4;
            }
        }

        if (menuPosition[0] < 0)
        {
            if (0.0f < angle && angle <= Mathf.PI / 12)
            {
                idCurrentButton = 4;
            }

            if (Mathf.PI / 12 < angle && angle <= 3 * Mathf.PI / 12)
            {
                idCurrentButton = 3;
            }

            if (3 * Mathf.PI / 12 < angle && angle <= 5 * Mathf.PI / 12)
            {
                idCurrentButton = 2;
            }

            if ((5 * Mathf.PI / 12 < angle && angle <= Mathf.PI / 2) || (-Mathf.PI / 2 <= angle && angle <= -5 * Mathf.PI / 12))
            {
                idCurrentButton = 1;
            }

            if (-5 * Mathf.PI / 12 < angle && angle <= -3 * Mathf.PI / 12)
            {
                idCurrentButton = 12;
            }

            if (-3 * Mathf.PI / 12 < angle && angle <= -Mathf.PI / 12)
            {
                idCurrentButton = 11;
            }

            if (-Mathf.PI / 12 < angle && angle <= 0.0)
            {
                idCurrentButton = 10;
            }
        }

        // Enfin, selon l'id du bouton, on fait l'échange de sélection entre les boutons
        if (idFormerButton != idCurrentButton)
        {
            selectedButton = boutons[idCurrentButton - 1];
            formerButton   = boutons[idFormerButton - 1];

            selectedButton.Select();
            formerButton.Deselect();

            idFormerButton = idCurrentButton;
        }
    }