/// <summary> /// Interpolate an array of Vector3 values /// </summary> /// <param name="tweenArr">Array of values</param> /// <param name="lerp"> lerp will likely be a ~0-1 value from AnimationCurve.Evaluate</param> /// <returns></returns> protected Vector3 LerpParameter(Vector3[] tweenArr, float lerp) { if ((useCurve && interpolationCurve.postWrapMode == WrapMode.Clamp) || (!useCurve && interpolation.nonCurveLoopMode == ProgramaticInterpolation.TweenLoopMode.Clamp)) { //We don't want random changing ever in this case if (currentLoop == 0) { SetRandom(tweenArr.Length); } } else { SetRandom(tweenArr.Length); } Vector3 scaleArrayLerp; if (tweenArr.Length == 2) { if (doRandomOffset) { if ((useCurve && interpolation.interpolation.postWrapMode == WrapMode.PingPong) || (!useCurve && interpolation.nonCurveLoopMode == ProgramaticInterpolation.TweenLoopMode.PingPong)) { if (currentLoop == 0) { randomValue = MathS.Vector3LerpUnclamped(newRandomOffsets[0], newRandomOffsets[1], lerp); } else if (currentLoop % 2 == 1) { randomValue = MathS.Vector3LerpUnclamped(newRandomOffsets[0], oldRandomOffsets[1], lerp); } else { randomValue = MathS.Vector3LerpUnclamped(oldRandomOffsets[0], newRandomOffsets[1], lerp); } } else { // if (!useCurve && interpolation.nonCurveLoopMode == ProgramaticInterpolation.TweenLoopMode.Continuous) { if (currentLoop == 0) { randomValue = MathS.Vector3LerpUnclamped(newRandomOffsets[0], newRandomOffsets[1], lerp); } else { randomValue = MathS.Vector3LerpUnclamped(oldRandomOffsets[0], newRandomOffsets[1], lerp % 1); } } //else { // randomValue = MathS.Vector3LerpUnclamped(oldRandomOffsets[0], newRandomOffsets[1],lerp); //} //randomValue = MathS.Vector3LerpUnclamped(newRandomOffsets[0], newRandomOffsets[1], lerp); // //MathS.Vector3Lerp(MathS.Vector3LerpUnclamped(randomOffsets[0], randomOffsets[1], lerp), //MathS.Vector3LerpUnclamped(newRandomOffsets[0], newRandomOffsets[1], lerp), count / timeSettings.time % 1); } scaleArrayLerp = MathS.Vector3LerpUnclamped(tweenArr[0], tweenArr[1], lerp) + randomValue; } else { scaleArrayLerp = LerpVector3Array(tweenArr, oldRandomOffsets, newRandomOffsets, lerp, count / time % 1); } if (EndIsRelativeOffsetFromStart && startRelative) { scaleArrayLerp = GetRelative(scaleArrayLerp, lerp); } else if (EndIsRelativeOffsetFromStart) { scaleArrayLerp = GetEndRelative(scaleArrayLerp, lerp); //+initial;//Vector3.Scale(scaleArrayLerp,initial); } else if (this.startRelative) { scaleArrayLerp = GetStartRelative(scaleArrayLerp, lerp); //MathS.Vector3Lerp(initial,scaleArrayLerp,lerp); } return(scaleArrayLerp); }
protected Color SetSaturation(Color inCol, float lerp) { var colorLum = Vector3.Dot(new Vector3(0.22f, 0.707f, 0.071f), new Vector3(inCol.r, inCol.g, inCol.b)); return(MathS.ColorLerpUnclamped(new Color(colorLum, colorLum, colorLum, inCol.a), inCol, lerp)); }