Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

How to change the height of a GUI.Window's title bar?

Discussion in 'Immediate Mode GUI (IMGUI)' started by kork, Jun 28, 2010.

  1. kork

    kork

    Joined:
    Jul 14, 2009
    Posts:
    280
    Hi,

    I am currently encountering a problem with the title bar of a GUI.Window. It seems to have a fixed size, no matter which font is used for it. This presents some rather ugly issue (see attached screenshot). I tried to fiddle with the skin for a while but there seems to be no way to increase the height of the title bar so the text fits in. Maybe some of the GUISkinners out there can help me with that...

    Kind regards,
    Jan
     

    Attached Files:

  2. TakuanDaikon

    TakuanDaikon

    Joined:
    Jun 6, 2010
    Posts:
    268
    Firstly, the title bar's actual height is set by the skin's Border property, specifically the Top portion of the border.

    Secondly, the title bar's size must match visually, which seems to be the problem you are experiencing. Unfortunately, that really has to be accounted for in the skin texture itself, as there really isn't any good way to change it on a texture that has such rounded corners.

    If you look at the Extra GUI Skins resource, you'll see how they have adjusted the skin's Window.Border property to match the actual texture used for each of the three included skins.

    When making your own skins, such as the snapshot below, you'll want to play with the Border, Padding, and ContentOffset values to get the titlebar looking as you wish.


    [/img]
     
    Radivarig likes this.
  3. kork

    kork

    Joined:
    Jul 14, 2009
    Posts:
    280
    Thank you for your pointers, I'll have a look at them. Regarding the creation of own skins, I still have problems in understanding how the graphic I create are used by Unity. I see edges are being repeated and corners stay, but I really would like to know the exact working of this. How big can I make a corner? Where can I set up which part gets repeated and which not? Is there any documentation on this? I searched the Unity docs but didn't come across something useful.
     
  4. TakuanDaikon

    TakuanDaikon

    Joined:
    Jun 6, 2010
    Posts:
    268
    Documentation is pretty sparse, unfortunately, but the extra skins pack helps a lot in my opinion.

    The Border property controls scaling by essentially breaking up the image into cells (like 9-slice scaling) :


    Cells 1, 3, 7, and 9 don't scale. Cells 2 and 8 scale horizontally, and height is controlled by border.Top and border.Bottom. Cells 4 and 6 only scale vertically, and their width is controlled by border.Left and border.Right, and cell 5 scales both horizontally and vertically.

    Corners can be any size you set up, but playing around with it will give you a feeling for what works well and what doesn't.

    .
     
  5. kork

    kork

    Joined:
    Jul 14, 2009
    Posts:
    280
    Way to go :) Thanks a lot, I'll check this out tonight.
     
  6. jahroy

    jahroy

    Joined:
    Apr 22, 2011
    Posts:
    10
    This thread is awesome.

    It's been very helpful to our team.

    Thanks!
     
unityunity