How to make progress bar adapt to different aspect ratio

HI, can anyone help me please with this problem:
I want to make a time progress bar in my game, I have two textures: progressBarFrame and progressBar. If I make it using OnGUI, like

void OnGui() {
GUI.DrawTexture ( Rect(x,y,width,height), progressBar );

It works, but GUI elements doesn’t adapt to different screen sizes.

I also tried this: Create GUITexture in the hierarchy and add texture to it, after adjusting its size and location as I need, progress bar stretches/squishes with different aspect ratioson and keeps its position relative to other GameObjects(that’s what I want). But I dont know how to animate it properly because the figure of the textures is not simple line.

first of all - please use code tags for ALL code. it’s the 101/010 button above the edit box.

if you’re writing c# then your OnGUI() function should look like this:

void OnGUI()
    GUI.DrawTexture( new Rect(x,y,width,height), progressBar);

note the function name change (upper case GUI) and the addition of ‘new’ - this is required in c#

a function called OnGui() will never be called by unity. everything is case sensitive…