I am engaged on a degree and click on system in Unity and I’ve a contextual menu that seems once you proper click on on an object. On this menu, there is a button known as “search” that strikes the participant to the item and opens a menu representing that object’s contents. The Search Button calls a way that takes a gameobject as a parameter; in different phrases, the item that the participant treats because the goal to which it strikes after which searches.
All of that is working simply superb, however there’s one drawback: At present I’ve two check containers, a crate and a barrel. The crate is the item that the button is taking as a parameter, so if I proper click on the barrel and choose “search”, the participant will go to look the crate.
How do I dynamically change the gameobject goal of the button in order that the search button will know the proper object it must be targetting, I.E. whichever object the participant proper clicked?