Button dont work

My button in game appear in screen correctly, see the image below:

But the actions when I click in button wont fired (debug or game actions)

        menuClicado = false;
        botaoClicado = "";
        contador = 0;
        foreach (Texture2D item in contextMenuItems)
        {
            itemr.x += itemDimensao.x * contador + 2f;
            itemr.width = itemDimensao.x;
            itemr.height = itemDimensao.y;
            if (item != null)
            {
                bool b = GUI.Button(itemr, item);
                if (b)
                {
                    menuClicado = true;
                    botaoClicado = item.name;
                    Debug.Log(selecao.ToString());
                    Debug.Log("Clicado em " + botaoClicado + " indicando para TorreGestor que a arvore " + selecao + " deve ser trocada");
                    GameObject.FindGameObjectWithTag("TorreGestor").GetComponent<TorreGestor>().trocarArvore(selecao, botaoClicado);
                    selecao = null;
                    menuClicado = false;
                    botaoClicado = "";
                    menuContexto = false;
                }
            }
            contador++;
        }

Every code is called on OnGUI()

Some idea ?

Not really, it seems fine.

Perhaps having duplicated scripts (rendering buttons 2 times on top of each other) and modifying only the single script?

No, because in my loop (for each…) I give a specific position for each button.
So the buttons are not ‘overlapping’.
The more strange…I put a button outside of loop and OK, the button works fine:

        if (GUI.Button(new Rect(0f, 240f, 100f, 100f), "Teste"))
        {
            Debug.LogWarning("Clicou no teste");
        }

You could try eliminating the variable definition, but I don’t see why that would make a difference.
if(GUI.Button(itemr, item))
{
}

I don’t think it could be the loop because almost everyone does that, but it’s logically the same thing using the definition. It drew the button so the size has to be correct.

I fix the problem…but is a thing that dont have any relation with the render of buttons.

Vector3 screenPosition = Camera.current.WorldToScreenPoint(selecao.transform.position);

I change the camera that give the initial position to draw buttons, and now works fine

Vector3 screenPosition = Camera.mainCamera.WorldToScreenPoint(selecao.transform.position);

See…