I have been running into several scenarios where I am needing to pass an argument along to a function when a button is pressed. I have been using crazy workarounds for some time now as I didn't really want to mess with the underlying core of NGUI scripts. Finally ran into a case where I needed to generate buttons at runtime that then needed the ability to pass specific GameObjects back to another object to be instantiated when that button was hit. This solution seems to be working great in this context.
(note in order to preserve NGUI's private code I am only posting the changes necessary to make this work)
around line 26 add this:
public Object parameter = null;
now find all instances of the call "SendMessage". There should only be 2 and located at the very bottom of the script in the "send" function (at time of writing).
replace the call of "SendMessage"
From:
SendMessage(functionName, gameObject, SendMessageOptions.DontRequireReceiver);
To:
SendMessage(functionName, parameter, SendMessageOptions.DontRequireReceiver);
Right now the "SendMessage" only supports one parameter (Unity thing), but there are some roundabout workarounds for getting more than one to pass.
If there was a specific reason that the generic "gameObject" was being passed instead of parameters, please let me know. So far this seems to be working for my needs.
Please let me know if there is any confusion or explanation needed