- Home /
Question by
Astrydax · Jun 30, 2021 at 01:46 AM ·
scripting problemuibuttonreference-other-object
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.
button.png
(22.5 kB)
Comment
Best Answer
Answer by Zaeran · Jun 30, 2021 at 06:11 AM
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.