UI Button - get reference to the parameter passed to function under OnClick()

I’m trying to write a simple script that will set the name of gameobject in the editor as well as the button displayed text to whatever the name of the object being passed to my buildcontroller.

For example, in this picture, I want the name of the object in the hierarchy, as well as the text on the button at runtime to both be “Base-no walls”.

I’ve duped myself too many times having to manually sync these three things up. I’d rather just require dragging the object into the parameter field and having a script do the naming.

182803-button.png

You can’t get access to the parameter directly through code. You’d need to write your own custom extension to the Button class and create an OnClick(object parameter) event.