yuyang9119 / UnityAssetStoreSupport

If you run into any issues using my assets, please submit feedback here.
4 stars 0 forks source link

How do I set the Interpolation mode with script? #24

Open Kecia0001 opened 2 years ago

Kecia0001 commented 2 years ago

It seems like I can get access to the animation by using => UnityExtensions.Tween.TweenTransformPosition anim_ = (UnityExtensions.Tween.TweenTransformPosition)_tween.GetAnimation(0);

anim_ has this function => Interpolate

but it doesn't seem to be that qìwhat I'm looking for.

I'd like to set the Interpolation to UnityExtensions.Tween.Interpolator.Sine, How can I achieve this? Thanks

yuyang9119 commented 2 years ago

Sorry, there is no way to set it through code, if necessary, it can be solved through reflection. anim.SetFieldValue("_interpolator", new CustomizableInterpolator(CustomizableInterpolator.Type.Sine));

Kecia0001 commented 2 years ago

Nice way. I instead solved this by using

   [SerializeField]
    CustomizableInterpolator _interpolator = default;
....
....
....

 if (_tween != null && _tween.animationCount > 0)
        {
            anim_ = (UnityExtensions.Tween.TweenTransformPosition)_tween.GetAnimation(0);
            anim_.Interpolate(_interpolator[_tween.normalizedTime]);
        }

Inside the LateUpdate method