Skip to content

Instantly share code, notes, and snippets.

@rutcreate
rutcreate / MyButton.cs
Last active March 11, 2024 00:02
Unity3D: Best way to add listener programmatically for Button onClick
using UnityEngine;
public class MyButton {
public Button[] buttons;
private void Start() {
for (int i = 0; i < buttons.Length; i++) {
Button button = buttons[i];
var index = i;