How to crop UI Image

Greetings!
I need to crop a UI image (that i use as healthbar) but apparently either I’m not good at searching things or can’t find the answer…
I don’t want to change the scale because its complicated image and it will look messy, I want to crop or show the image based of the remaining life.

Any information is welcome I will do my best in that one!

You must set the image type to “Filled” in inspector.

If it’s a health bar, your settings will be:

ImageType - Filled

Fill Method - horizontal

Fill Origin - left

Fill Amount - 1 (values go from 1 to 0) << Use that with scripting to reduce the healt :wink:

You can use a “Mask” component which will make all child objects that are in the same aria as it visible.

If you create a UI Image then add a mask script then create a new UI Component as a child of the GameObject with a mask, the child will only appear where the parent GameObject is visible. There is also a checkbox on the Mask component to hide the mask image.

I was looking for this in unity 2017 and it seems to be hidden until you add a Source Image. Hopefully this is helpful to someone else.

https://forum.unity.com/threads/how-do-you-clip-an-image-with-another.944266/#post-6161944