How can I make a textured power bar

Hi everyone,

It’s a 3D game in top view (without gravity), it consists to launch a projectile from a position A, the final position of the mouse give the second point B, the vector AB is the direction of the launch and the magnitude of the vector is proportional to the power of launch.

My problem is graphic, I tried to do a textured power bar to the position of the mouse but the texture stretches and compresses depending on the size of the bar.
This is a picture to be more clear

32315-illustation.jpg

So it’s possible to make it like the second picture?

If you’re using the 4.6 Open Beta uGUI , you can make the image component’s image type filled and set it to horizontal , then simply clamp your health from 0 to 1 and put the result in “Fill Amount”. If you’re using legacy , well i don’t know :confused:

Thanks for the reply

I used a cylinder for my power bar, and I applied this script to control its “y” tiling proportionaly to the scale of my bar :

renderer.material.mainTextureScale = new Vector2 (1, AB.magnitude);

a little picture to illustrate the result