Masking GUI elements

I’ve been messing around with various methods to create an energymeter-like GUI-element.

This is what I would like to generate:

As I see it, I have two options:

#1: Create a sprite for each level the blue bar could be at.
#2: Create the blue bar using a plane/cube inside Unity that I scale along the Y-axis.

Solution #2 would be the best in my opinion, but how should i do this? I’ve tried to do this with this culling-shader, but that only generates this result:

In other words; the masking isn’t happening dynamically.

Can anyone help me out? Am I trying to solve this in all the wrong ways?

Thank you for your time.



233467--8355--$energymeterfront_198.jpg

Another option would be to use GUI.DrawTexture to draw a blue box representing the liquid and then draw the thermometer texture over it at a fixed size.