This recipe has a few key elements that make it work:
- Image Type set to Filled: Unity provides the Filled Image type for the UI Image components. It fills the image from left to right (or in any other desired direction).
- Fill Amount reference in scripts: The fill amount of an image can be changed through scripts: it's a public variable of the Image class.