UnityEditor.EulerCurveCombinedRenderer.EvaluateCurveSlow C# (CSharp) Method

EvaluateCurveSlow() public method

public EvaluateCurveSlow ( float time, int component ) : float
time float
component int
return float
        public float EvaluateCurveSlow(float time, int component)
        {
            if (this.GetCurveOfComponent(component).length == 1)
            {
                Keyframe keyframe = this.GetCurveOfComponent(component)[0];
                return keyframe.value;
            }
            if (time == this.cachedEvaluationTime)
            {
                return this.cachedEvaluationValue[component];
            }
            if ((time < this.cachedRangeStart) || (time > this.cachedRangeEnd))
            {
                this.CalculateCurves(this.rangeStart, this.rangeEnd);
                this.cachedRangeStart = float.NegativeInfinity;
                this.cachedRangeEnd = float.PositiveInfinity;
            }
            float[] numArray = new float[this.points.Count];
            Vector3[] vectorArray = new Vector3[this.points.Count];
            int index = 0;
            foreach (KeyValuePair<float, Vector3> pair in this.points)
            {
                numArray[index] = pair.Key;
                vectorArray[index] = pair.Value;
                index++;
            }
            for (int i = 0; i < (numArray.Length - 1); i++)
            {
                if (time < numArray[i + 1])
                {
                    float t = Mathf.InverseLerp(numArray[i], numArray[i + 1], time);
                    this.cachedEvaluationValue = Vector3.Lerp(vectorArray[i], vectorArray[i + 1], t);
                    this.cachedEvaluationTime = time;
                    return this.cachedEvaluationValue[component];
                }
            }
            if (vectorArray.Length > 0)
            {
                return vectorArray[vectorArray.Length - 1][component];
            }
            Debug.LogError("List of euler curve points is empty, probably caused by lack of euler curve key synching");
            return 0f;
        }

Usage Example

示例#1
0
 public float EvaluateCurveSlow(float time)
 {
     return(renderer.EvaluateCurveSlow(time, component));
 }