Answer the question
In order to leave comments, you need to log in
How to disable the button?
I need it to turn off when the button is pressed, because when it is pressed, it calls up a menu that closes this button. .interactable and .enabled don't work. If someone had such a problem, or if you know how to solve it, please tell me what to do?
Answer the question
In order to leave comments, you need to log in
I understood why .interactable didn't work. In general, if you're going to use .interactable then make sure you don't have a script named "Button" as it will throw an error.
You can write a bool variable in the script where there is a public void of this button, which will initially be true. And in the method, write it to be executed only when the variable is true, and then make it false. So you can make the button work only once, and then (if necessary) set true again)
Something like this:
bool tor = true;
public void for_knopka(){
if(tor){
//тело функции
tor = false;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question