Author Topic: How to make ngui sprite at runtime?  (Read 1876 times)


  • Jr. Member
  • **
  • Thank You
  • -Given: 5
  • -Receive: 0
  • Posts: 90
    • View Profile
How to make ngui sprite at runtime?
« on: December 25, 2014, 04:11:51 AM »
So I am thinking about buff showing system,

like most MMO game(World of Warcraft, etc), if character has some status like good of bad, icon appear below of portrait, so user know what sort of buff/debuff effect put on.

So I need to make this sort of system for my game,

if character got status, status (buff/debuff) icon (+its name) should appear, how can I make this?

Instantiate ngui sprite+label prefab?

or can I generate ngui sprite at runtime?

or more good way exist?



  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How to make ngui sprite at runtime?
« Reply #1 on: December 28, 2014, 11:54:28 AM »
Create a prefab for what a visible buff should look like that would handle things such as setting its sprite properly and giving you hover over tooltip functionality, etc. When you get buffed, NGUITools.AddChild this prefab to your buff panel (or better yet -- a grid underneath it so that it's automatically positioned). Have the script attached to this prefab monitor the status of the buff. When the buff is no longer there -- NGUITools.Destroy its game object, thus removing the visible buff too.