I have a Filled Image used to represent skill cooldown. For the first time, the filled image works properly. After that, the image is completely gone even though the Fill Amount is still being updated (as seen in the inspector)
Weird thing, whenever I click on anything in the Image inspector, the image shows up and works properly again (just for one run).
Here’s a quick fix for those who have the same problem. I’m not sure what’s happening under the hood but whenever you set Image.fillAmount to 0, the image never gets rendered.
If there’s a less-hacky/proper way to do this, please tell me.
EDIT: Setting the fillAmount value to near zero also keeps the image from rendering. I make sure that the value is at least 0.001f to make it work.
public class TestFilledImage : MonoBehaviour {
private Image image;
private float fillAmount;
// Use this for initialization
void Start () {
image = GetComponent<Image>();
}
// Update is called once per frame
void Update () {
if (fillAmount >= 1.0f) fillAmount = 0;
else fillAmount += Time.deltaTime * 0.2f;
image.fillAmount = Mathf.Max(fillAmount, 0.001f);
}
}