Search Unity

Having trouble understanding HUD scaling

Discussion in 'Immediate Mode GUI (IMGUI)' started by Noxwill, Jun 20, 2013.

  1. Noxwill

    Noxwill

    Joined:
    Apr 16, 2013
    Posts:
    18
    I'm having trouble understanding how to do this.

    I have a HUD that comprises 3 GUITextures placed at the bottom of the screen.

    I noticed afterwards that if I resize my screen, the textures aren't fixed and will not scale and stay in their original positions to match the screen.

    Is there a way to make it so the textures always fill the screen according to an original placement? And if you're in free-scale mode, they scale with the resolution no matter what?
     
  2. dkozar

    dkozar

    Joined:
    Nov 30, 2009
    Posts:
    1,410
    UnityGUI sizes are in pixel coordinates, so that's why it doesn't scale.

    If you want to scale you have 2 options:

    1. Use scaling (GUIUtility.ScaleAroundPivot or similar)
    2. Detect screen resize and recalculate GUI element sizes according to the screen size (better, because you are in pixel domain and you can avoid bluriness)