Hyluss icon

[Unity] AddListener to button

Hyluss | PRO | 04/24/18 09:42:14 PM UTC | 0 ⭐ | 382 👁️ | Never ⏰ | []
C# |

360 B

|

None

|

0 👍

/

0 👎

    private void Awake()
    {      
        Button[] buttons = gridWithMaps.GetComponentsInChildren<Button>();
        scrollBar.numberOfSteps = buttons.Length;
 
        foreach (var button in buttons)
        {
            button.onClick.AddListener( () => onMapClick(button));
        }
    }
 
    void onMapClick(Button button)
    {
        //todo
    }

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎