- Home /
Ui Elements and Unity Events
When using UnityEvents with an UI elements like OnValueChange for an Input Fields. Is it possible to have access to the object from which the event is raised ?
Let's imagine that I want to process something and apply this processing to multiples UI elements without having to create a specific function for each of those.
Thank a lot.
Answer by fafase · Aug 25, 2015 at 07:33 AM
I would use a normal event in this case. UnityEvent is good for simple events, when you get to a more complex system, you should get back to .NET event.
But anyway, you added the method to the listener slot. If the method is meant to receive a parameter, it will show an extra slot above the method. Then you can drag the GameObject holding the script as I would guess it is one calling the event.
Thanks, I simply used a Static Parameter with the Input Field itself. So I can access to the object who raised the On Value Changed event.
Your answer
Follow this Question
Related Questions
ScrollRect and IDragHandler on touch devices 1 Answer
Place UI element on pointer up position. 1 Answer
Unity 4.6B UI Scrollbar Usage 1 Answer
Offsetting RectTransform based on button state button 1 Answer
UI Dropdown does not drop. 7 Answers