Demigiant / dotween

A Unity C# animation engine. HOTween v2
http://dotween.demigiant.com
Other
2.3k stars 346 forks source link

Missing DoFillAmount in Dotween Animation component #604

Closed Baccanno closed 1 year ago

Baccanno commented 1 year ago

Hi, The DOFillAmount func is missing from the list of tweens in the component UI. I tried adding it myself, by looking at the Fade code, because values behaves the same, though I can't see were you bind the enum with the function.

image

//Enum list for component retrieval I guess
{ DOTweenAnimation.AnimationType.UIWidthHeight, new[] { typeof(RectTransform) } },
{ DOTweenAnimation.AnimationType.FillAmount, new[] { typeof(Image) } },

//UI list
       static readonly string[] _AnimationType = new[] {
            "None",

            nameof(DOTweenAnimation.AnimationType.FillAmount),

//Switch
                    case DOTweenAnimation.AnimationType.FillAmount:
                        _src.endValueFloat = 0;
                        break;
                    case DOTweenAnimation.AnimationType.Color:
                    case DOTweenAnimation.AnimationType.Fade:
                        _isLightSrc = targetGO.GetComponent<Light>() != null;
                        _src.endValueFloat = 0;
                        break;

//Other switch
                case DOTweenAnimation.AnimationType.Fade:
                case DOTweenAnimation.AnimationType.FillAmount:
                    GUIEndValueFloat();
                    if (_src.endValueFloat < 0) _src.endValueFloat = 0;
                    if (!_isLightSrc && _src.endValueFloat > 1) _src.endValueFloat = 1;
                    canBeRelative = false;
                    break;
Baccanno commented 1 year ago

Found this, getting closer

                case AnimationType.FillAmount:
                    isRelative = false;
                    switch (targetType)
                    {
                        case TargetType.Image:
                            tween = ((Image)target).DOFillAmount(endValueFloat, duration);
                            break;

                    }
                    break;
                case AnimationType.Fade:
                isRelative = false;
                switch (targetType) {
Baccanno commented 1 year ago

All values seems set correctly, when previewing though it does not seem to update the fill amount value, however the tween runs for 1 sec. As not a GO target, the target is set to the one enclosing the component. Has it any infuence ?

Baccanno commented 1 year ago

Okay it does work perfectly. Just had to check "Always update" in the editor image

Baccanno commented 1 year ago

So here is the POC I'll let you merge it :) ?

Demigiant commented 1 year ago

Ahoy!

I dug deeper into the editor preview system and found a hack that allows UI FillAmount/Color/Fade editor previews to work even if you don't enable "always update" in the editor :) If you write me here I will send you a full update