public void SetValue(double newVal) { if (double.IsNaN(newVal) || double.IsInfinity(newVal)) { return; } if (!m_isInit) { LastRawValue = RawValue = newVal; m_isInit = true; Debug.Log("Key: " + key + "获得的最初值为" + newVal); return; } else { LastRawValue = RawValue; RawValue = newVal; } if (raw) { TargetValue = RawValue; } else { if (isDegree) { var delta = (RawValue - LastRawValue); TargetValue = TGUtility.PreventValueSkipping(TargetValue, LastRawValue, RawValue, reverse); } else { int sign = (reverse) ? -1 : 1; float dist = ( float )(RawValue - LastRawValue); TargetValue += dist * sign; } } if (damp > 0) { value = Mathf.Lerp(( float )value, ( float )TargetValue, damp); } else { value = TargetValue; } }
public void SetValue(double newVal) { if (_delayFrame > 0) { _delayFrame--; return; } if (double.IsNaN(newVal)) { newVal = 0f; } if (!m_isInit) { LastRawValue = RawValue = newVal; m_isInit = true; } else { LastRawValue = RawValue; RawValue = newVal; } if (raw) { value = (float)RawValue; return; } if (isDegree) { value = TGUtility.PreventValueSkipping(value, LastRawValue, RawValue, reverse); } else { int sign = (reverse) ? -1 : 1; float dist = (float)(RawValue - LastRawValue); value += dist * sign; } }