void Tick()
{
if (Event.current.type == EventType.Repaint)
{
float deltaTime = Time.realtimeSinceStartup - lastUpdate;
// Right at the start of a transition the deltaTime will
// not be reliable, so use a very small value instead
// until the next repaint
if (value == 0f || value == 1f)
{
deltaTime = 0.001f;
}
deltaTime = Mathf.Clamp(deltaTime, 0.00001F, 0.1F);
// Larger regions fade slightly slower
deltaTime /= Mathf.Sqrt(Mathf.Max(lastRect.height, 100));
lastUpdate = Time.realtimeSinceStartup;
float targetValue = open ? 1F : 0F;
if (!Mathf.Approximately(targetValue, value))
{
value += deltaTime * animationSpeed * Mathf.Sign(targetValue - value);
value = Mathf.Clamp01(value);
editor.Repaint();
if (!fancyEffects)
{
value = targetValue;
}
}
else
{
value = targetValue;
}
}
}