When I run this custom action without the everyFrame check box clicked, the debug line will never show in the console (which is intended). However, when I click the everyFrame checkbox, the console only shows the debug line once. Any idea why? Here is my code:
public class GetCurrentHP : FsmStateAction
{
//Public
[RequiredField]
public FsmGameObject gameObject;
[RequiredField]
[UIHint(UIHint.Variable)]
public FsmFloat storeValue;
public bool everyFrame;
//Private
float unitinfoValue;
UnitInfo varUnitInfo;
string strDebug;
public override void Reset()
{
storeValue = null;
gameObject = null;
everyFrame = false;
}
public override void OnEnter()
{
varUnitInfo = gameObject.Value.GetComponent<UnitInfo>();
unitinfoValue = varUnitInfo.GetMaxHealth();
storeValue.Value = unitinfoValue;
if (!everyFrame)
Finish();
}
public override void OnUpdate()
{
varUnitInfo = gameObject.Value.GetComponent<UnitInfo>();
unitinfoValue = varUnitInfo.GetMaxHealth();
storeValue.Value = unitinfoValue;
//Debug
strDebug = Convert.ToString(storeValue.Value);
Debug.Log("Running OnUpdate() and the value is "+strDebug);
}
}
}