- Home /
Question by
ItsaMeTuni · Feb 22, 2016 at 09:51 AM ·
c#buttoncanvaslisteners
Right click listener - generated canvas buttons
I know how to add an onClick listener to a button that is generated by script, the only problem is that it just detects left mouse button clicks. And I need it to detect left and right mouse button clicks to make an inventory system.
To add a onClick listener:
slot.GetComponent<Button>().onClick.AddListener(() => { SlotClick(); });
where:
slot is the button
SlotClick is the function
And I would like to know how the AddListener syntax works. Like what means it's parameters:
() => { SlotClick(); }
Thanks in advance and sorry if my english is bad :)
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612065127im_/https://answers.unity.com/themes/thub/images/avi.jpg)