In the lecture, the way to bind the onclick event is using serialized filed to pass in the button variable and use onClick.AddListener() to subscribe to a function. I wonder is there any different between this method or create the onClick event from button and drag in the DialogueUI?
No, it’s the same thing. The inspector bits are just an easy way to do it. Usually designers don’t write code, so they don’t want to be adding listeners in the code. This allows a designer to add listeners without the code. But this method is not always possible, either. If we are dynamically adding buttons to something during gameplay we don’t have the luxury of an inspector to drag stuff onto. So, we use code
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.