Clamp01() public static method

public static Clamp01 ( float value ) : float
value float
return float
Exemplo n.º 1
0
        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;
                }
            }
        }
Exemplo n.º 2
0
 public static Vector2 Lerp(Vector2 a, Vector2 b, float t)
 {
     t = Mathf.Clamp01(t);
     return(new Vector2(a.x + ((b.x - a.x) * t), a.y + ((b.y - a.y) * t)));
 }
Exemplo n.º 3
0
 public static Vector3d Lerp01t(Vector3d from, Vector3d to, float t)
 {
     return(Lerp(from, to, Mathf.Clamp01(t)));
 }
Exemplo n.º 4
0
 public static Vector4 Lerp(Vector4 a, Vector4 b, float t)
 {
     t = Mathf.Clamp01(t);
     return(new Vector4(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t, a.z + (b.z - a.z) * t, a.w + (b.w - a.w) * t));
 }
Exemplo n.º 5
0
 public static Color Lerp(Color a, Color b, float t)
 {
     t = Mathf.Clamp01(t);
     return(new Color(a.r + (b.r - a.r) * t, a.g + (b.g - a.g) * t, a.b + (b.b - a.b) * t, a.a + (b.a - a.a) * t));
 }