Hello everybody, I can´t figure this out, and after spending two days looking for an answer on the web, I´m out of resources, maybe someone can help me with this.
I have three UI buttons, same components:
Inside each one I call this Method from script PressedButton:
public class PressedButton : MonoBehaviour
{
private string myName = "";
public void ButtonName()
{
var nombre = EventSystem.current.currentSelectedGameObject;
myName = nombre.name;
if (nombre != null)
{
textMeshProUGUI.text = "" + myName;//... mostrarlo en el textField
//THIS SHOW IN THE TEXT FIELD ALWAYS THE RIGHT BUTTON NAME
}
else { return; }
}
//here is -i think- the problem:
public string BotonPresionado()
{
return myName;
}
}
And from script B, I try to “talk” to BotonPresionado () like this:
void Start ()
{
InvokeRepeating("MainFigureChanger", 0f, 1.5f);
}
void MainFigureChanger()
{
QueBotonAprete();
}
void QueBotonAprete()
{
var botonNuevo = PresssedButton.BotonPresionado();
Debug.Log(botonNuevo);
}
But here, no matter what, I only get a result if I click the first button (from left to right). The only way to get another name is if I disable the first button (I already try changing the z depth of the button, just in case, with no luck)
Hopefully somebody will get an idea of what may be wrong here… Thanks to all for reading!