Beispiel #1
0
        /// <summary>
        /// Transforms the curve range.
        /// </summary>
        /// <param name="curve">Curve.</param>
        /// <param name="min">Minimum value.</param>
        /// <param name="max">Maximum value.</param>
        /// <param name="samplingFrequency">
        /// Sampling frequency (<see cref="UnityEngine.Mathf.Epsilon"/>, <see cref="UnityEngine.Mathf.Infinity"/>).
        /// </param>
        public static void TransformRange(this AnimationCurve curve, float min, float max, float samplingFrequency)
        {
            float high, low;

            curve.GetRange(out high, out low, samplingFrequency);
            curve.TransformRange(min, max, low, high);
        }
Beispiel #2
0
        /// <summary>
        /// Gets the status of a backing field whose should be within the range [0, 1].
        /// </summary>
        /// <returns>The normalized range profile status.</returns>
        /// <param name="provider">Provider.</param>
        /// <param name="testValue">Test value.</param>
        /// <param name="message">Message.</param>
        private static ValidationStatus GetNormalizedRangeCurveStatus(
            object provider, object testValue, out string message
            )
        {
            AnimationCurve curve = (AnimationCurve)testValue;

            if (curve == null)
            {
                message = "Backing field is not an AnimationCurve.";
                return(ValidationStatus.Error);
            }
            float high, low;

            curve.GetRange(out high, out low, GetSamplingFrequencyForInspector(curve));
            if (high > 1f || low < 0f)
            {
                message = "This curve falls outside the range [0, 1].";
                return(ValidationStatus.Warning);
            }
            message = "";
            return(ValidationStatus.None);
        }