void Update()
{
if (Input.GetMouseButton(0))
{
Debug.Log(“Test”);
if (gameObject.name == “Decrease”)
{
Debug.Log(“Test1”);
bar = GameObject.Find(“Bar”);
bar.transform.localScale += new Vector3(-0.01875F, 0, 0);
}
else if (gameObject.name == “Increase”)
{
Debug.Log(“Test2”);
bar = GameObject.Find(“Bar”);
bar.transform.localScale += new Vector3(0.01875F, 0, 0);
}
}
}
The code works fine under OnMouseDown, but when I put it under Update, the scale is increased once no matter where on screen I click and nothing else seems to work anymore except for the test messages. And for some reason I get 8 messages every frame for Test message (1 for other messages), though I think there should be only 1 per frame.