I have a button in my scene calling this function when it is pressed:
public void ScanAsteroid() {
_scan = true;
}
It runs and if I put a debug statement in, it will output something like “Scan Asteroid Running” but the variable does not change. That proves that the function is running, but the varaible isn’t changing. Why is that and how can I fix it?
public class ValueChangable : MonoBehaviour
{
private int Value = 5;
public bool Click = false;
public void Start()
{
Debug.Log (Value);
}
public void ValueChange()
{
Value = Value + 10;
Debug.Log (Value);
}
}
Here this will increase the value, once you press the button. Here i used the integer variable. and simply used by single script without any condition.
public class ValueChangable : MonoBehaviour
{
private int Value;
public bool Click = false;
public void Start()
{
Debug.Log (Value);
}
public void ValueChange()
{
Click = true;
Debug.Log (Value);
}
void Update()
{
if(Click == true)
{
Value = 10;
Click = false;
}
}
}
Here i used the boolean variable and use update function for changing the variable.
Do you want like this or more than this.