Skip to main content
3 of 4
code formatting and spelling
bummzack
  • 22.6k
  • 5
  • 63
  • 87

How to make progress bar adapt to various aspect ratios in Unity3d

Can anyone help me with this problem: I want to make a time progress bar in my game. I have two textures: progressBarFrame and progressBar. Currently I'm doing the following:

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

It works, but it doesn't adapt to different screen sizes.

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

JJ91
  • 11
  • 1
  • 5