Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: matt1 on September 02, 2013, 09:59:39 AM

Title: Scaling UI sprite like EXP bar, health bar etc
Post by: matt1 on September 02, 2013, 09:59:39 AM
Hi there,

I am looking to scale many UI elements like Health bar, mana, energy and experience. I've acheived this reletively easy before with Unity's GUI system, however I am a little lost doing it with NGUI.

Originally I done it like:

  1. GUI.Box(new Rect(100 ,Screen.height - 100,PercentageCalculator(PlayerExp,ExpToLevel)* Screen.width / 150, 25), "EXP");
  2.  
  3. public float PercentageCalculator(float x, float y) {
  4.                 return(x / y * 100);
  5.         }
  6.  

However I can't controll the scale with of the UISprite using this method.

Any ideas would be appreciated!

Thanks
Title: Re: Scaling UI sprite like EXP bar, health bar etc
Post by: Slyfox on September 02, 2013, 11:52:04 AM
If you select your UISprite object, then choose Sprite type : filled, and Fill Dir : horizontal then you can control the fill amount and obtain something similar to what you are asking.
Title: Re: Scaling UI sprite like EXP bar, health bar etc
Post by: matt1 on September 04, 2013, 08:44:39 AM
I completely forgot about this >.< Thanks a bunch!