Author Topic: HUDText performance problem?  (Read 2792 times)

alexlange

  • Newbie
  • *
  • Thank You
  • -Given: 5
  • -Receive: 0
  • Posts: 34
    • View Profile
HUDText performance problem?
« on: February 06, 2014, 02:19:07 AM »
Hi, I'm using HUDText in my iOS game. Each HUDText follow a character to display damages.
In the worst situation, there'll be 14 characters keep popping up numbers via HUDText(not too heavy, right?).


At first I didn't give it much attention in Editor. 0.6ms is quite affordable.

Things change when I run it on iPad2. As you can see, HUDText took around 8ms for each frame, sometimes it can up to 16ms.

So I'm wondering what costs alot on mobile device, and how to fix it.
Now a few potential reasons appear but I have no idea which have higher priority.
First comes to my mind is transparent, where HUDText uses to fade out numbers, because Game.Renderer for transparent is also heavy for my scene.
Then I find UIFollowTarget.Update() have Camera.WorldToViewportPoint in it, will it costs alot if I have so many characters?

Any suggestion to optimize my game? Thank you!

NGUI: 3.4.8
HUDText: 1.1
Editor: Mac mini (16G mem & SSD)
Device: iPad2

* I changed UIFollowTarget a bit so particles can follow UI, mainly is a SetTarget function and an offset.
  1. void Update ()
  2.         {
  3.                 Vector3 pos = gameCamera.WorldToViewportPoint(target.position+mOffset);
« Last Edit: February 06, 2014, 02:32:20 AM by alexlange »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: HUDText performance problem?
« Reply #1 on: February 06, 2014, 10:53:33 PM »
The process of changing things is an expensive one, and HUDText items change a lot as they have to follow objects and animate. Make sure that all your HUDText items are under their own UIPanel. This way their changes won't affect the rest of the UI.