How to disable a button after click in c#?
I've some buttons that i need to disable them after clicking using C# script.
Answer by umar.geniteam · Aug 26, 2015 at 01:17 PM
public void BtnOnClick() { gameObject.GetComponent<Button>().interactable = false; }
set BtnOnClick as your onclick method for the button
the button is still interactable. it cant be disabled with this code. help
An old question and answer but brilliant, did exactly what I needed
Answer by junedmmn · Jan 13, 2017 at 10:22 AM
public Button button1;
public void DisableButtonOnClick() { button1.interactable = false; }
//Drag the button1 in the main camera or where the script is present
hi! i want to know how to clear check Toggle after click save button in unity c#
@sitinurulain1905 , You will need to access isOn()
method of Toggle.
public Toggle toggle;
public void $$anonymous$$ethod()
{
// set to Checked
toggle.IsOn() = true;
// set to Unchecked
toggle.isOn() = false;
}
call the method with required code when button is clicked. Drag the Toggle from Hierarchy to the Script in Inspector.