Author Topic: Scaling UI sprite like EXP bar, health bar etc  (Read 3705 times)

matt1

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 28
    • View Profile
Scaling UI sprite like EXP bar, health bar etc
« 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

Slyfox

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 12
    • View Profile
Re: Scaling UI sprite like EXP bar, health bar etc
« Reply #1 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.

matt1

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 28
    • View Profile
Re: Scaling UI sprite like EXP bar, health bar etc
« Reply #2 on: September 04, 2013, 08:44:39 AM »
I completely forgot about this >.< Thanks a bunch!