# Shrink GUI

**URL:** https://discussions.unity.com/t/shrink-gui/29267
**Category:** Questions & Answers
**Created:** [September 30, 2011, 1:15pm UTC](https://discussions.unity.com/t/shrink-gui/29267 "2011-09-30T13:15:48Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![henry96](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/henry96/32/331620_2.png) [@henry96](https://discussions.unity.com/u/henry96)
#### Post date: [September 30, 2011, 1:15pm UTC](https://discussions.unity.com/t/shrink-gui/29267/1 "2011-09-30T13:15:48Z")

</div>

Hello, guys. Now I’m facing with another issue. I made texture for the player’s health. I used `OnGUI ()` to make it. When the health drops, I reduce the width of the GUI. However, when it is reduces, it also affects the height. So how can I solve that? Thank you!

Here is my code :

```
var healthBar : Texture2D;

var health : int = 100;

function OnGUI ( ) {

var screenPos : Vector3 = camera.main.WorldToScreenPoint (transform.position);

GUI.Label (Rect (screenPos.x, Screen.height - screenPos.y, health / 2, 100), healthBar);

}

```

---

<div class="post-metadata">

### Author: ![syclamoth](https://avatars.discourse-cdn.com/v4/letter/s/d26b3c/32.png) [@syclamoth](https://discussions.unity.com/u/syclamoth)
#### Post date: [September 30, 2011, 2:24pm UTC](https://discussions.unity.com/t/shrink-gui/29267/2 "2011-09-30T14:24:56Z")

</div>

Textures getting stretched/squashed is a setting you have to set up in the GUIStyle. Try defining a custom [GUIStyle](http://unity3d.com/support/documentation/ScriptReference/GUIStyle.html) for your health-bars, and then tick ‘stretchHeight’ to true. By default it doesn’t like messing with your texture sizes, but for something like a health bar, it’s obviously desired behaviour.
