toggle unity example
Example 1: 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
}
Example 2: how to use toggle in unity
using.UnityEgnigne.UI;
public class ToggleScript : MonoBehaviour
{
public Toggle toggle;
void Update()
{
if(toggle.isOn)
{
//Do stuff
}
}
}