Here are 3 integers and 1 bool.
int a;
int b;
int c;
bool bHasChangedValue;
The boolean value bHasChangedValue depends on the value of b changing.
If I update b each frame
public void Update()
{
a = b;
b += c;
bHasChangedValue = a != b;
}
bHasChangedValue becomes true if b has changed.
A problem occurs if I set the value of b outside the Update method though.
public void SetB(int value)
{
if (b == value)
{
return;
}
b = value;
bHasChangedValue = true;
}
Because b has changed, bHasChangedValue is set to true. When the update is called, if c is 0 then bHasChangedValue will be set to false, which isn't correct in this case.
How can I keep the bHasChangedValue as true for one Update if it was set outside Update?