Hyluss

[Unity] AddListener to button

Apr 24th, 2018
419
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.36 KB | None | 0 0
  1.     private void Awake()
  2.     {      
  3.         Button[] buttons = gridWithMaps.GetComponentsInChildren<Button>();
  4.         scrollBar.numberOfSteps = buttons.Length;
  5.  
  6.         foreach (var button in buttons)
  7.         {
  8.             button.onClick.AddListener( () => onMapClick(button));
  9.         }
  10.     }
  11.  
  12.     void onMapClick(Button button)
  13.     {
  14.         //todo
  15.     }
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment