- Home /
Multiple Actions for a single button
My problem today is probably nothing to do with Unity but more so C# programming. What I want to accomplish is to have a GUILayout.Button call, dynamically, multiple functions from different sources. I already have it able to call one function, with arguments, but after I had that issue resolved I realized I needed some buttons to call multiple functions instead of just one.
Here's my Show method of the ButtonInfo class: (p_Params is an ArrayList, and _t is a string)
public void Show()
{
if(GUILayout.Button(_t))
{
if(p_callSet && !p_callParams)
p_Params.Add("None");
this._callback( this.p_Params );
}
}
What I'd like to do is have it so before the callback is executed, I can sift through the p_Params to find only the arguments pertaining to the button. I know I can accomplish this through nested for-loops, but I think Im overlooking something as I'm not sure if it'd work properly.
Any help would be appreciated.
You could use events rather than a callback to hit multiple interested parties. There's no need to use this. in your code.
I don't really understand what p_params is or p_callParams