When I click on the button, the toggle switches, but sometimes 2-3times / click, and the state of button changes that times too of course, the button blinks too, so I randomly get the same result of the toggle as in the beginning.
my question is that, should be this code correct? and is the root of the problem somewhere else in the code?
or maybe I need a timer in this, or something else to work this out?
void Update()
{
if (coll.collider.gameObject.layer == 9)
{
if (Input.GetMouseButtonDown(1) )
{
toggle().active = !toggle().active;
}
}
}
thx Tom
and sorry for grammar