- Home /
Changing the target of a button that takes a gameobject as a parameter?
I'm working on a point and click RPG system and I have a contextual menu that appears when you right click on an object. In this menu, there's a button called "search" that moves the player to the object and opens a menu representing that object's contents.
All of this is working just fine, but there's one problem: the Search Button calls a method that takes a gameobject as a parameter; in other words, the object that the player treats as the target to which it moves and then searches. Currently I have two test containers, a crate and a barrel. The crate is the object that the button assigns as the search target, so if I right click the barrel and select "search", the player will go to search the crate.
How do I dynamically change the gameobject target of the button so that the search button will know the correct object it should be targetting?
Your answer
![](https://koobas.hobune.stream/wayback/20220613061050im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
UI Button not sending event on IOS build only 1 Answer
UI: Mouse events not working 1 Answer
Event system or UI Button ? 0 Answers
How to set UI button as selected on mouse over 1 Answer
UI button always selected? 0 Answers