I have put this code for a button in my game:
if(Input.GetMouseButtonUp(0))
{
if(ButtonArea.Contains(MousePos) Time.timeSinceLevelLoad - TimeSinceLastClick > 2f);
{
TimeSinceLastClick = Time.timeSinceLevelLoad;
ConstObject.ShowButtons = !ConstObject.ShowButtons;
print ("test");
}
}
For some odd reason, every time it’s clicked it prints out test twice and turns the bool to the opposite, then back. Even if I take out the TimeSinceLastClick like this:
if(Input.GetMouseButtonUp(0))
{
if(ButtonArea.Contains(MousePos));
{
ConstObject.ShowButtons = !ConstObject.ShowButtons;
print ("test");
}
}
It will still print twice, I originally thought that for some reason GetMouseButtonUp was running for 2 scenes, however the time should have fixed that. Also if I make the if statement all one line like this:
if(ButtonArea.Contains(MousePos) Time.timeSinceLevelLoad - TimeSinceLastClick > 0.5f);
{
TimeSinceLastClick = Time.timeSinceLevelLoad;
ConstObject.ShowButtons = !ConstObject.ShowButtons;
print ("test");
}
test is printed out constantly. I have no idea what’s going on here, any suggestions?