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 ?