How o know what is the GameObjectName of a button?
Hi, im making a loop that takes a string (gameobject name) and a bool (status to apply)
The loops go inside a list of Button type and check to see if he button's GamePbject is equal to the string parameter, if so, give it "interactable = status" (maybe i want to use it to disable only this button or enable only this button)
Quesion: How can i check for the Button, what is the name of the GameObject's name that is containing it? (when creating a UI button is a GameObject with Button component apply to it)
string comparison is prone to errors, i would suggest adding an extra component with an enum identifier, and on the button event route it through your component and to the target with your custom identifier. That way you can include as much information as you want.
If you have the reference to the Button Component the name of it's gameobject would be
buttoncomponent.gameObject.name
Your answer
Follow this Question
Related Questions
Button object has no attribute OnClick 1 Answer
Assigning a GameObject variable to equal another GameObject variable via C# script. 0 Answers
How to keep bool true even when other method try to set it off 0 Answers
Activate when mouse klick object 1 Answer
Move gameObject on UI Button Press 2 Answers