Hi everybody, im using this code:
public int index;
private Button myselfButton;
void Start()
{
myselfButton = GetComponent<Button>();
}
void Update () {
if (Input.GetMouseButtonUp(0))
{
myselfButton.onClick.AddListener(() => actionToMaterial(index));
}
}
void actionToMaterial(int idx)
{
Debug.Log("change material to HIT on material : " + idx);
}
and when i click on the button, console write me some debug, in one time, but i need call this function only one. How can i do it? Anybody knows what im doing wrong?
Thanks