Author Topic: Filled Sprites  (Read 2479 times)

dohjoka

  • Guest
Filled Sprites
« on: July 19, 2013, 07:29:08 PM »
Am new to NGUI , I liked the way you can change fill amount of a filled sprite in a game , I know I can do that manually in the inspector but how would I do it through scripting?
I am making a health bar and I want to make a script that reduces the the sprite due to damage.
I can't seem to get to that UIScript and to that fillAmount variable.

thanks.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Filled Sprites
« Reply #1 on: July 20, 2013, 04:02:37 AM »

dohjoka

  • Guest
Re: Filled Sprites
« Reply #2 on: July 20, 2013, 04:06:52 AM »
Thank you ArenMook,

you may call me a noob but if I want to access this variable from an outside script how would I initialize all the components in order to do that ?

again I appreciate your help.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Filled Sprites
« Reply #3 on: July 20, 2013, 04:09:09 AM »
Same way you access any other component. You must get it first:

UISprite sprite = GetComponent<UISprite>();
sprite.fillAmount = 0.5f;