internal RotationData(float time, float duration, IEnumerable <float> startRotation, IEnumerable <float> endRotation, string easing) : base(time, duration) { this.startRotation = EnumerableToQuaternion(startRotation) ?? savedRotation; this.endRotation = EnumerableToQuaternion(endRotation) ?? this.startRotation; savedRotation = this.endRotation; this.easing = string.IsNullOrEmpty(easing) ? Easings.Functions.easeLinear : (Easings.Functions)Enum.Parse(typeof(Easings.Functions), easing); }
public ResizeObjectTask(Transform obj, Vector3 targetSize, Easings.Functions type, float timeToFinish) { _object = obj; _targetSize = targetSize; _type = type; _timeToFinish = timeToFinish; }
public CameraPositionZoomResetProcess(Camera camera, float duration, Vector2 position, float zoom, Easings.Functions easingFunction = Easings.Functions.Linear) : base(duration) { _endPosition = position; _endZoom = zoom; Camera = camera; EasingFunction = easingFunction; }
public EasingNumber(double start, double end, int delay, Easings.Functions easing) { Start = start; End = end; Delay = delay; Easing = easing; }
public static IEnumerator FadeMove(Transform trans, Vector3 end, float time, Easings.Functions fun = Easings.Functions.Linear) { float startTime = Time.time; Vector3 startPos = trans.localPosition; Vector3 move = end - startPos; float mult = -9999.9f; while (Time.time - startTime < time) { mult = (Time.time - startTime) / time; mult = Easings.Interpolate(mult, fun); Vector3 x = startPos + move * mult; trans.localPosition = x; yield return(null); } trans.localPosition = end; #if (PRINT) Debug.Log("Coroutine 'FadeMove' ended in " + (Time.time - startTime)); #endif }
IEnumerator Interpolation(Easings.Functions mode, float duration) { if (-EPSILON < duration && duration < EPSILON) { yield break; } yield return(null); var t = (duration > 0f ? 0f : 1f); var ds = 1f / duration; NotifyOnBegin(t); while (true) { t += Time.deltaTime * ds; if (t < 0f || 1f < t) { break; } Func(Easings.Interpolate(t, mode)); yield return(null); } Func(Easings.Interpolate(Mathf.Clamp01(t), mode)); NotifyOnEnd(t); _coroutine = null; }
/// <summary> /// Creates a new instance of the <see cref="LayerPropertyKeyframe{T}" /> class /// </summary> /// <param name="value">The value of the keyframe</param> /// <param name="position">The position of this keyframe in the timeline</param> /// <param name="easingFunction">The easing function applied on the value of the keyframe</param> /// <param name="layerProperty">The layer property this keyframe is applied to</param> public LayerPropertyKeyframe(T value, TimeSpan position, Easings.Functions easingFunction, LayerProperty <T> layerProperty) { _position = position; Value = value; LayerProperty = layerProperty; EasingFunction = easingFunction; }
public AnimatedRectangle(Rectangle rectangle, TimeSpan animatedTime, Easings.Functions easingFunction) { Current = rectangle; _targetRectangle = rectangle; _startRectangle = rectangle; SetAnimatedTime(animatedTime); _easingFunction = easingFunction; }
public Easer Interpolate(Easings.Functions mode, float duration) { Stop(); if (_bhv.isActiveAndEnabled) { _coroutine = _bhv.StartCoroutine(Interpolation(mode, duration)); } return(this); }
public EntityScaleProcess(Engine engine, Entity entity, float duration, float startScale, float endScale, Easings.Functions easingFunction = Easings.Functions.Linear) : base(duration) { Engine = engine; Entity = entity; EasingFunction = easingFunction; StartScale = startScale; EndScale = endScale; }
public FlatFXSettings(FlatFXType type, int sectorCount, float lifetime, Easings.Functions easing, float randomizePosition, FlatFXState start, FlatFXState end) { this.type = type; this.sectorCount = sectorCount; this.lifetime = lifetime; this.easing = easing; this.randomizePosition = randomizePosition; this.start = start; this.end = end; }
public FlatFXParticle(FlatFXType type, float lifetime, int sectorCount, Easings.Functions easing, FlatFXState start, FlatFXState end) { this.type = type; this.lifetime = lifetime; this.sectorCount = sectorCount; this.easing = easing; this.start = start; this.end = end; this.createdTime = Time.time; }
public WidgetClassFadeAnimation(Root root, string className, float startAlpha, float endAlpha, float duration, Easings.Functions easingFunction = Easings.Functions.Linear) : base(duration) { Root = root; ClassName = className; StartAlpha = startAlpha; EndAlpha = endAlpha; EasingFunction = easingFunction; }
public PropertyTrackEasingViewModel(PropertyTrackKeyframeViewModel keyframeViewModel, Easings.Functions easingFunction) { _keyframeViewModel = keyframeViewModel; _isEasingModeSelected = keyframeViewModel.Keyframe.EasingFunction == easingFunction; EasingFunction = easingFunction; Description = easingFunction.Humanize(); CreateGeometry(); }
public TimelineEasingViewModel(Easings.Functions easingFunction, bool isSelected) { _isEasingModeSelected = isSelected; EasingFunction = easingFunction; Description = easingFunction.Humanize(); EasingPoints = new PointCollection(); for (int i = 1; i <= 10; i++) { int x = i; double y = Easings.Interpolate(i / 10.0, EasingFunction) * 10; EasingPoints.Add(new Point(x, y)); } }
private static IEnumerator ExecuteInterpolation <T>(Easings.Functions interpolator, float duration, Action <T> interaction, T from, T to, Action <T> OnFinish, Func <T, T, float, T> formula) { float sT = Time.time; float eT = sT + duration; while (Time.time < eT) { float t = (Time.time - sT) / duration; float interpolatedValue = Easings.Interpolate(t, interpolator); var value = formula(from, to, interpolatedValue); interaction(value); yield return(new WaitForEndOfFrame()); } interaction(to); OnFinish?.Invoke(to); }
/// <summary> /// Curved interpolation of a point in 2D /// </summary> /// <param name="transform"></param> /// <param name="locationTo"></param> /// <param name="time"></param> /// <param name="interpolationType"></param> /// <param name="rotationNormalised"></param> /// <param name="offsetZ"></param> /// <param name="isUnscaledTime"></param> /// <returns></returns> public static IEnumerator FancyInterpolation(Transform target, Vector3 locationTo, float time, Easings.Functions interpolationType = Easings.Functions.QuarticEaseInOut, bool rotationNormalised = true, float offsetZ = 0, bool isUnscaledTime = false) { const int functionsCount = 21; // based on Easings.Functions Easings.Functions typeOfInterpolationX = (Easings.Functions)UnityEngine.Random.Range(0, functionsCount); Easings.Functions typeOfInterpolationY = (Easings.Functions)UnityEngine.Random.Range(0, functionsCount); Easings.Function interpolatorX = Easings.GetInterpolator(typeOfInterpolationX); Easings.Function interpolatorY = Easings.GetInterpolator(typeOfInterpolationY); Easings.Function interpolatorFraction = Easings.GetInterpolator(interpolationType); float fraction = 0; float speed = 1 / time; Vector3 currentPosition = target.position + Vector3.forward * offsetZ; Quaternion currentRotation = target.rotation; Quaternion rotationTo = Quaternion.Euler(Vector3.zero); float totalDisanceX = locationTo.x - currentPosition.x; float totalDisanceY = locationTo.y - currentPosition.y; if (rotationNormalised) { while (fraction < 1) { float resultX; Vector3 offsetToMoveBy = FancyInterpolationSplitResult(totalDisanceX, totalDisanceY, fraction, speed, isUnscaledTime, interpolatorFraction, interpolatorX, interpolatorY, out resultX); target.position = currentPosition + offsetToMoveBy; Quaternion newRotation = Quaternion.Lerp(currentRotation, rotationTo, resultX); target.rotation = newRotation; yield return null; } } else { while (fraction < 1) { float resultX; // not used Vector3 offsetToMoveBy = FancyInterpolationSplitResult(totalDisanceX, totalDisanceY, fraction, speed, isUnscaledTime, interpolatorFraction, interpolatorX, interpolatorY, out resultX); target.position = currentPosition + offsetToMoveBy; yield return null; } } }
public TweenPropertyBase SetInterpolation(Easings.Functions function) { this.function = function; return(this); }
public override void OnInspectorGUI() { int labelWidth = 120; EditorGUIUtility.labelWidth = labelWidth + 4; //Export/Import presets EditorGUILayout.BeginHorizontal(); GUILayout.Label(new GUIContent("Manage presets", "Export settings for all effects to an external file or import them back"), GUILayout.Width(labelWidth)); if (GUILayout.Button(new GUIContent("Import...", "Import FlatFX settings tro a JSON file."))) { LoadSettings(); } if (GUILayout.Button(new GUIContent("Export...", "Export FlatFX settings from a previously exported JSON file."))) { SaveSettings(); } EditorGUILayout.EndHorizontal(); //Show particle count and triangle count EditorGUILayout.BeginHorizontal(); GUILayout.Box(new GUIContent("Effect count: " + script.particleCount.ToString()), EditorStyles.helpBox); GUILayout.Box(new GUIContent("Triangle count: " + script.triangleCount.ToString()), EditorStyles.helpBox); EditorGUILayout.EndHorizontal(); //FX toolbar string[] enumstrings = FlatFXType.GetNames(typeof(FlatFXType)); Texture[] buttons = new Texture[enumstrings.Length]; for (int i = 0; i < buttons.Length; i++) { buttons[i] = (Texture)Resources.Load("Icons/FX" + enumstrings[i]); } int switchState = GUILayout.Toolbar(script.selectedEffect, buttons, GUILayout.Height(28)); if (switchState != script.selectedEffect) { GUI.FocusControl(null); script.selectedEffect = switchState; } //Decide which settings to show and edit FlatFXSettings showSettings = script.settings[switchState]; //Sector count int sectorCount = EditorGUILayout.IntField(new GUIContent("Sector count", "Determines how many sectors the effect will have"), showSettings.sectorCount); if (sectorCount != showSettings.sectorCount) { Undo.RecordObject(script, "Edit settings"); showSettings.sectorCount = sectorCount; EditorUtility.SetDirty(script); } //Lifetime float lifetime = EditorGUILayout.FloatField(new GUIContent("Lifetime", "How long the effect will exist"), showSettings.lifetime); if (lifetime != showSettings.lifetime) { Undo.RecordObject(script, "Edit settings"); showSettings.lifetime = lifetime; EditorUtility.SetDirty(script); } //Easing function Easings.Functions easing = (Easings.Functions)EditorGUILayout.EnumPopup(new GUIContent("Easing function", "The function that specifies how this effect will be animated"), showSettings.easing); if (easing != showSettings.easing) { Undo.RecordObject(script, "Edit settings"); showSettings.easing = easing; EditorUtility.SetDirty(script); } //Randomize position float randomizePosition = EditorGUILayout.FloatField(new GUIContent("Randomize position", "Sets the max distance where the effect will appear"), showSettings.randomizePosition); if (randomizePosition != showSettings.randomizePosition) { Undo.RecordObject(script, "Edit settings"); showSettings.randomizePosition = randomizePosition; EditorUtility.SetDirty(script); } //Labels for start and end EditorGUILayout.BeginHorizontal(); GUILayout.Label(" ", GUILayout.Width(labelWidth)); GUILayout.Label(new GUIContent("Start:", "Starting conditions for the effect")); GUILayout.Label(new GUIContent("End:", "Final conditions for the effect")); EditorGUILayout.EndHorizontal(); //Size EditorGUILayout.BeginHorizontal(); GUILayout.Label(new GUIContent("Size:", "Sets both width and height of the effect"), GUILayout.Width(labelWidth)); float startSize = EditorGUILayout.FloatField(showSettings.start.size); if (startSize != showSettings.start.size) { Undo.RecordObject(script, "Edit settings"); showSettings.start.size = startSize; EditorUtility.SetDirty(script); } float endSize = EditorGUILayout.FloatField(showSettings.end.size); if (endSize != showSettings.end.size) { Undo.RecordObject(script, "Edit settings"); showSettings.end.size = endSize; EditorUtility.SetDirty(script); } EditorGUILayout.EndHorizontal(); //Thickness EditorGUILayout.BeginHorizontal(); GUILayout.Label(new GUIContent("Thickness:", "How much of the total size the effect will fill"), GUILayout.Width(labelWidth)); float startThickness = EditorGUILayout.FloatField(showSettings.start.thickness); if (startThickness != showSettings.start.thickness) { Undo.RecordObject(script, "Edit settings"); showSettings.start.thickness = startThickness; EditorUtility.SetDirty(script); } float endThickness = EditorGUILayout.FloatField(showSettings.end.thickness); if (endThickness != showSettings.end.thickness) { Undo.RecordObject(script, "Edit settings"); showSettings.end.thickness = endThickness; EditorUtility.SetDirty(script); } EditorGUILayout.EndHorizontal(); //Inner color EditorGUILayout.BeginHorizontal(); GUILayout.Label(new GUIContent("Inner color:", "Sets color for inner vertices"), GUILayout.Width(labelWidth)); Color startInnerColor = EditorGUILayout.ColorField(showSettings.start.innerColor); if (startInnerColor != showSettings.start.innerColor) { Undo.RecordObject(script, "Edit settings"); showSettings.start.innerColor = startInnerColor; EditorUtility.SetDirty(script); } Color endInnerColor = EditorGUILayout.ColorField(showSettings.end.innerColor); if (endInnerColor != showSettings.end.innerColor) { Undo.RecordObject(script, "Edit settings"); showSettings.end.innerColor = endInnerColor; EditorUtility.SetDirty(script); } EditorGUILayout.EndHorizontal(); //Outer color EditorGUILayout.BeginHorizontal(); GUILayout.Label(new GUIContent("Outer color:", "Sets color for outer vertices"), GUILayout.Width(labelWidth)); Color startOuterColor = EditorGUILayout.ColorField(showSettings.start.outerColor); if (startOuterColor != showSettings.start.outerColor) { Undo.RecordObject(script, "Edit settings"); showSettings.start.outerColor = startOuterColor; EditorUtility.SetDirty(script); } Color endOuterColor = EditorGUILayout.ColorField(showSettings.end.outerColor); if (endOuterColor != showSettings.end.outerColor) { Undo.RecordObject(script, "Edit settings"); showSettings.end.outerColor = endOuterColor; EditorUtility.SetDirty(script); } EditorGUILayout.EndHorizontal(); GUILayout.Space(10); //Test button EditorGUILayout.BeginHorizontal(); GUILayout.Box(new GUIContent("Effect #" + switchState.ToString() + ": " + enumstrings[switchState]), EditorStyles.helpBox, GUILayout.Width(labelWidth)); if (GUILayout.Button(new GUIContent("Test", "Add this effect to the scene. Keep in mind that framerate is lower when in edit mode. Hit play to test effects in proper framerate."))) { script.AddEffect(script.transform.position, switchState); } EditorGUILayout.EndHorizontal(); //Sprite sorting GUILayout.Space(10); //Get sorting layers int[] layerIDs = GetSortingLayerUniqueIDs(); string[] layerNames = GetSortingLayerNames(); //Get selected sorting layer int selected = -1; for (int i = 0; i < layerIDs.Length; i++) { if (layerIDs[i] == script.sortingLayer) { selected = i; } } //Select Default layer if no other is selected if (selected == -1) { for (int i = 0; i < layerIDs.Length; i++) { if (layerIDs[i] == 0) { selected = i; } } } //Sorting layer dropdown EditorGUI.BeginChangeCheck(); GUIContent[] dropdown = new GUIContent[layerNames.Length + 2]; for (int i = 0; i < layerNames.Length; i++) { dropdown[i] = new GUIContent(layerNames[i]); } dropdown[layerNames.Length] = new GUIContent(); dropdown[layerNames.Length + 1] = new GUIContent("Add Sorting Layer..."); selected = EditorGUILayout.Popup(new GUIContent("Sorting Layer", "Name of the Renderer's sorting layer"), selected, dropdown); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(script, "Change sorting layer"); if (selected == layerNames.Length + 1) { EditorApplication.ExecuteMenuItem("Edit/Project Settings/Tags and Layers"); } else { script.sortingLayer = layerIDs[selected]; } EditorUtility.SetDirty(script); } //Order in layer field EditorGUI.BeginChangeCheck(); int order = EditorGUILayout.IntField(new GUIContent("Order in Layer", "Renderer's order within a sorting layer"), script.orderInLayer); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(script, "Change order in layer"); script.orderInLayer = order; EditorUtility.SetDirty(script); } }
public static IEnumerator FadeImageFillAmount(Image im, Vector2 range, float time, Easings.Functions fun = Easings.Functions.Linear) { float startTime = Time.time; float numb = range.y - range.x; float add = 0; while (Time.time - startTime < time) { add = range.x + numb * Easings.Interpolate((Time.time - startTime) / time, fun); im.fillAmount = add; yield return(null); } im.fillAmount = range.y; #if (PRINT) Debug.Log("Coroutine 'FadeImageFillAmount' ended in " + (Time.time - startTime)); #endif }
public static void _Interpolate(this MonoBehaviour monoBehaviour, Vector3 from, Vector3 to, Action <Vector3> interaction, float duration, Easings.Functions interpolator = Easings.Functions.Linear, Action <Vector3> onFinish = null) { monoBehaviour.StartCoroutine(ExecuteInterpolation(interpolator, duration, interaction, from, to, onFinish, Vector3.Lerp)); }
public static IEnumerator FadeImageColor(Image im, Vector2 range, float time, bool[] arr, Easings.Functions fun = Easings.Functions.Linear) { float startTime = Time.time; float numb = range.y - range.x; float add = 0; while (Time.time - startTime < time) { add = range.x + numb * Easings.Interpolate((Time.time - startTime) / time, fun); im.color = ColorChange(im.color, arr, add); yield return(null); } im.color = ColorChange(im.color, arr, range.y); #if (PRINT) Debug.Log("Coroutine 'FadeImageColor' ended in " + (Time.time - startTime)); #endif }
public static Easer Interpolate(this MonoBehaviour bhv, Easings.Functions mode, float duration) { return(new Easer(bhv).Interpolate(mode, duration)); }
public static IEnumerator FadeSoundVolume(AudioSource audio, Vector2 range, float time, Easings.Functions fun) { float startTime = Time.time; float numb = range.y - range.x; float add = 0; while (Time.time - startTime < time) { add = range.x + numb * Easings.Interpolate((Time.time - startTime) / time, fun); audio.volume = add; yield return(null); } audio.volume = range.y; #if (PRINT) Debug.Log("Coroutine 'FadeSoundVolume' ended in " + (Time.time - startTime)); #endif }
public static IEnumerator FadeSequence(SpriteRenderer im, Vector2 range, float time, Easings.Functions fun, SpriteArray sa) { float startTime = Time.time; float numb = range.y - range.x; float add = 0; int index = 0; int lastIndex = -99; int length = sa.alphaMaskSequence.Length - 1; while (Time.time - startTime < time) { add = range.x + numb * Easings.Interpolate((Time.time - startTime) / time, fun); index = (int)(add * length); if (index != lastIndex) { im.material.SetTexture("_DissolveTex", sa.alphaMaskSequence[index]); lastIndex = index; } yield return(null); } im.material.SetTexture("_DissolveTex", sa.alphaMaskSequence[(int)(range.y * length)]); #if (PRINT) Debug.Log("Coroutine 'FadeSequence' ended in " + (Time.time - startTime)); #endif }
// Token: 0x06000001 RID: 1 RVA: 0x00002050 File Offset: 0x00000250 public static float Interpolate(float p, Easings.Functions function) { switch (function) { default: return(Easings.Linear(p)); case Easings.Functions.QuadraticEaseIn: return(Easings.QuadraticEaseIn(p)); case Easings.Functions.QuadraticEaseOut: return(Easings.QuadraticEaseOut(p)); case Easings.Functions.QuadraticEaseInOut: return(Easings.QuadraticEaseInOut(p)); case Easings.Functions.CubicEaseIn: return(Easings.CubicEaseIn(p)); case Easings.Functions.CubicEaseOut: return(Easings.CubicEaseOut(p)); case Easings.Functions.CubicEaseInOut: return(Easings.CubicEaseInOut(p)); case Easings.Functions.QuarticEaseIn: return(Easings.QuarticEaseIn(p)); case Easings.Functions.QuarticEaseOut: return(Easings.QuarticEaseOut(p)); case Easings.Functions.QuarticEaseInOut: return(Easings.QuarticEaseInOut(p)); case Easings.Functions.QuinticEaseIn: return(Easings.QuinticEaseIn(p)); case Easings.Functions.QuinticEaseOut: return(Easings.QuinticEaseOut(p)); case Easings.Functions.QuinticEaseInOut: return(Easings.QuinticEaseInOut(p)); case Easings.Functions.SineEaseIn: return(Easings.SineEaseIn(p)); case Easings.Functions.SineEaseOut: return(Easings.SineEaseOut(p)); case Easings.Functions.SineEaseInOut: return(Easings.SineEaseInOut(p)); case Easings.Functions.CircularEaseIn: return(Easings.CircularEaseIn(p)); case Easings.Functions.CircularEaseOut: return(Easings.CircularEaseOut(p)); case Easings.Functions.CircularEaseInOut: return(Easings.CircularEaseInOut(p)); case Easings.Functions.ExponentialEaseIn: return(Easings.ExponentialEaseIn(p)); case Easings.Functions.ExponentialEaseOut: return(Easings.ExponentialEaseOut(p)); case Easings.Functions.ExponentialEaseInOut: return(Easings.ExponentialEaseInOut(p)); case Easings.Functions.ElasticEaseIn: return(Easings.ElasticEaseIn(p)); case Easings.Functions.ElasticEaseOut: return(Easings.ElasticEaseOut(p)); case Easings.Functions.ElasticEaseInOut: return(Easings.ElasticEaseInOut(p)); case Easings.Functions.BackEaseIn: return(Easings.BackEaseIn(p)); case Easings.Functions.BackEaseOut: return(Easings.BackEaseOut(p)); case Easings.Functions.BackEaseInOut: return(Easings.BackEaseInOut(p)); case Easings.Functions.BounceEaseIn: return(Easings.BounceEaseIn(p)); case Easings.Functions.BounceEaseOut: return(Easings.BounceEaseOut(p)); case Easings.Functions.BounceEaseInOut: return(Easings.BounceEaseInOut(p)); } }
IEnumerator <float> _AnimationCoroutine(Vector3 startPos, Vector3 endPos, float duration, Easings.Functions easingType, GameObject objectToAnimate) { //Animation process for (float time = 0f; time < duration; time += Time.deltaTime) { //if gameObject exists if (objectToAnimate != null) { time = Mathf.Clamp(time, 0f, duration); float value = MathW.Remap(time, 0f, duration, 0f, 1f); Vector3 currentPosition = Vector3.LerpUnclamped(startPos, endPos, Easings.Interpolate(value, easingType)); objectToAnimate.transform.position = currentPosition; yield return(Timing.WaitForOneFrame); } //if gameObject was destroyed while being animated else { Debug.LogWarning("Animation Coroutine: objectToAnimate was destroyed"); yield break; } //ensure that the final position is exactly the target position objectToAnimate.transform.position = endPos; } }
private void StartAnimation(Vector3 startPos, Vector3 endPos, float duration, Easings.Functions easingType, GameObject objectToAnimate) { //Stop previous coroutine, if it's animating the same object Timing.KillCoroutines(objectToAnimate.GetInstanceID(), "AnimateToTargetPosition"); //Start animation coroutine Timing.RunCoroutine(_AnimationCoroutine(startPos, endPos, duration, easingType, objectToAnimate), objectToAnimate.GetInstanceID(), "AnimateToTargetPosition"); }
/// <summary> /// Moves from one size to another dynamically /// </summary> /// <param name="transform"> Transform obj to be scaled</param> /// <param name="scaleTo"> Scale to</param> /// <param name="time"> Time it takes to scale</param> /// <param name="interpolationFunction"> Scaling interpolator</param> /// <param name="isUnscaledTime"> Is not paused</param> /// <returns></returns> public static IEnumerator InterpolateRectPositionE(RectTransform rectTransform, Vector3 pointTo, float time = 1, Easings.Functions interpolationFunction = Easings.Functions.Linear) { //rectTransform.position = new Vector3(0, 0, 0); Vector3 currentPosition = rectTransform.localPosition; Easings.Function interpolator = Easings.GetInterpolator(interpolationFunction); float fraction = 0; float speed = 1 / time; bool isUnscaledTime = GeneralHelper.IsPaused(); float easedValue; while (fraction < 1) { fraction = fraction.To1(speed, isUnscaledTime, interpolator, out easedValue); Vector3 newPosition = Vector3.Lerp(currentPosition, pointTo, easedValue); rectTransform.localPosition = newPosition; yield return null; } }
/// <summary> /// Interpolates between 2 points 2D /// </summary> /// <param name="to"> Destination point</param> /// <param name="target"> Target to be interpolated</param> /// <param name="speed"> /speed is the time it takes to travel</param> public static IEnumerator InterpolatePointE(Transform target, Vector2 to, float time, Easings.Functions interpolationFunction = Easings.Functions.Linear) { Easings.Function interpolator = Easings.GetInterpolator(interpolationFunction); float fraction = 0; float speed = 1 / time; bool isUnscaledTime = GeneralHelper.IsPaused(); Vector2 from = target.position; float easedValue; while (fraction < 1) { fraction.To1(speed, isUnscaledTime, interpolator, out easedValue); target.transform.position = Vector2.Lerp(from, to, easedValue); yield return null; } }