Image on game object is not being rendered

I am creating a health bar for a 2D game, and would like to use the Image API. I have a sprite to use for the game player’s health status, and want to make use of the Image API’s Filled property.

I’m having a problem with the image showing up, though. If I create a gameobject, and attach a sprite to it with a sprite renderer, then I have no problems and it shows up fine. However, if I attach an image to a gameobject, and the sprite to that image, the image doesn’t show up in the scene or in the game, and Z-layering does not appear to be an issue.

What am I doing wrong that is making my image not render?

I solved this problem. I was not aware that an image had to be placed on a canvas. When I added the canvas to the game object, it worked just fine for me.

If you have the same problem, add a ‘canvas’ component to your game object. you can then modify the canvas to modify your image.