2
« on: December 03, 2014, 09:22:24 PM »
Hello,
I was hoping someone could help me with what I want to do with UIEventListener. I've created a "Dialogue" Prefab in my game and it has images/text/buttons associated with it. I can change all those at will, but I want to be able to dynamically change the function pointed to by the UIEventListner so I can make it generic and call a function in the script which created the dialogue window. Something like this...
In Town.CS
>inn.transform.GetComponent<dialogue_class>().active_listen_button1(inn_function);
> void inn_function(GameObject button)
> {
> inn.transform.GetComponent<dialogue_class>().close_listen_button1(inn_function);
> // Do Stuff - Button was Clicked and Listener is now off
> }
In dialogue_class.CS
>public void active_listen_button1(string target_function)
> { UIEventListener.Get(inn.transform.FindChild("Button - Action 1").gameObject).onClick += target_function; }
>public void close_listen_button1(string target_function)
> { UIEventListener.Get(inn.transform.FindChild("Button - Action 1").gameObject).onClick -= target_function; }
If anyone could help, I'd appreciate it. Been struggling with this issue for a couple hours and I can't seem to make it work.