unity toggle scrfipt code example
Example: toggle unity c#
private bool togl;//this is either true or false
if (Input.GetKey(KeyCode.A)) //can have whatever statment you want here
{
togl = !togl; //this is what changes the bool
}