Support > NGUI 3 Support

Animating sprite fill and color does not work


Hello There

I am creating short tutorial animations explaining the basics of a game. For this I am using the same NGUI sprites as the sprites in the working ingame interface except these sprites have no functional logic attached to them.

I am using mecanim to animate al the tutorial events. The problem is when I want to color a sprite or change a fill setting of a sprite using the animation editor, this does not get animated. The panel is not checked as being static...

Does anybody know if this is a known issue?

"MFill" is a private variable. Animating it doesn't notify the widget that it changed. The fact that it shows up in the animator is an old Unity bug.

All NGUI interaction is done via properties instead UIWidget.fillAmount is what should be modified. If you want to do it via an animation, you need to write an intermediate script like so:
using UnityEngine; [ExecuteInEditMode][RequireComponent(typeof(UIWidget))]public class AnimatedFill : MonoBehaviour{    [Range(0f, 1f)]    public float fillAmount = 1f;     UIWidget mWidget;     void Awake () { mWidget = GetComponent<UIWidget>(); }    void Update () { mWidget.fillAmount = fillAmount; }}Attach this script to your widget and animate this script's "fillAmount" value instead of "MFill".

Great Aren,

Thank you very much for the reply, this will help us a great deal. Now we know for sure that we will have to use this small workaround.

Right now we use mecanim to move panels in and out of the screen i would think that with all the focus on mecanim from unity, NGUI would benefit from embracing the animation tool as a great addition to the NGUI workflow. Thanks again


The only way to "embrace" it is to expose variables making them public, and then check to see if they changed in every single Update(). This will hurt performance.

This extra component approach lets you animate things, and it won't affect performance of UI elements that are not animated.

hello, i'm facing the same problem and i tried this script but mWidget.fillAmount is not defined anymore, what i have to use to replace it?


[0] Message Index

Go to full version