UnityEngine.Mathf.SmoothStep C# (CSharp) Method

SmoothStep() public static method

public static SmoothStep ( float from, float to, float t ) : float
from float
to float
t float
return float
        public static float SmoothStep(float from, float to, float t)
        {
            if (t < 0.0f)
                return from;
            if (t > 1.0f)
                return to;
            t = t * t * (3.0f - 2.0f * t);
            return (1.0f - t) * from + t * to;
        }

Usage Example

コード例 #1
0
        void OnDrawGizmosInternal()
        {
            var newGizmoHash = pickNextWaypointDist.GetHashCode() ^ slowdownDistance.GetHashCode() ^ endReachedDistance.GetHashCode();

            if (newGizmoHash != gizmoHash && gizmoHash != 0)
            {
                lastChangedTime = Time.realtimeSinceStartup;
            }
            gizmoHash = newGizmoHash;
            float alpha = alwaysDrawGizmos ? 1 : Mathf.SmoothStep(1, 0, (Time.realtimeSinceStartup - lastChangedTime - 5f) / 0.5f) * (UnityEditor.Selection.gameObjects.Length == 1 ? 1 : 0);

            if (alpha > 0)
            {
                // Make sure the scene view is repainted while the gizmos are visible
                if (!alwaysDrawGizmos)
                {
                    UnityEditor.SceneView.RepaintAll();
                }
                Draw.Gizmos.Line(position, steeringTarget, GizmoColor * new Color(1, 1, 1, alpha));
                Gizmos.matrix = Matrix4x4.TRS(position, transform.rotation * (rotationIn2D ? Quaternion.Euler(-90, 0, 0) : Quaternion.identity), Vector3.one);
                Draw.Gizmos.CircleXZ(Vector3.zero, pickNextWaypointDist, GizmoColor * new Color(1, 1, 1, alpha));
                Draw.Gizmos.CircleXZ(Vector3.zero, slowdownDistance, Color.Lerp(GizmoColor, Color.red, 0.5f) * new Color(1, 1, 1, alpha));
                Draw.Gizmos.CircleXZ(Vector3.zero, endReachedDistance, Color.Lerp(GizmoColor, Color.red, 0.8f) * new Color(1, 1, 1, alpha));
            }
        }
All Usage Examples Of UnityEngine.Mathf::SmoothStep