Author Topic: NGUI Iphone 4 (iOS6) performance  (Read 4721 times)

jimbbq

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 25
    • View Profile
NGUI Iphone 4 (iOS6) performance
« on: May 28, 2014, 05:56:48 AM »
Dear all

I have a major problem with NGUI performance on Iphone.

I only have two labels displaying the scores and lives in the game. I did try to add a fancy effect to the text labels (by making them big and changing their colours when the scores and lives change), but it has caused me several days of nightmares trying to figure out what is causing the hitch in my game. I removed the labels, and now everything is running very smoothly.

I really like how easy it is to use NGUI to build pretty GUI, but it slows down the game performance on iphone so much! Is there a way I can improve the performance of NGUI?

thanks!

BehindTheStone

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 135
    • View Profile
Re: NGUI Iphone 4 (iOS6) performance
« Reply #1 on: May 28, 2014, 06:29:25 AM »
That's weird. I have a lot of UISprites (Buttons) and also some labels displayed + all the stuff which is rendered by the MainCamera (2D Toolkit Sprites + Animations) and I have usually 60FPS on my iPhone 4.

You use "Application.targetFrameRat = 60" somewhere and have your VSync Count set to "Don't Sync", yes?

jimbbq

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 25
    • View Profile
Re: NGUI Iphone 4 (iOS6) performance
« Reply #2 on: May 28, 2014, 06:47:42 AM »
thanks for the reply.

Please tell me more about "You use "Application.targetFrameRat = 60" somewhere and have your VSync Count set to "Don't Sync", yes?"

I don't know any of these!  :-[  How do I do this?

hexaust

  • Newbie
  • *
  • Thank You
  • -Given: 14
  • -Receive: 1
  • Posts: 35
    • View Profile
Re: NGUI Iphone 4 (iOS6) performance
« Reply #3 on: May 28, 2014, 06:54:32 AM »
You can set the target frame rate inside the Awake function. Something like:

  1. void Awake () {
  2.     Application.targetFrameRate = 60;
  3. }
  4.  

As for the VSync Count option you will find it in the Unity menu.

Edit > Project Settings > Quality




jimbbq

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 25
    • View Profile
Re: NGUI Iphone 4 (iOS6) performance
« Reply #4 on: May 28, 2014, 07:41:39 AM »
thanks. I did it, the problem still exists..... to clarify , the game runs smoothly in general, but there are occasional hitches which I think are due to label update

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI Iphone 4 (iOS6) performance
« Reply #5 on: May 28, 2014, 07:49:19 AM »
When label text updates, it causes the entire draw call to be rebuilt, meaning all the other labels and widgets that use the same atlas and are underneath the same panel will have to be rebuilt. So if you have 1000 widgets and you change 1, all 1000 will be affected.

BehindTheStone

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 135
    • View Profile
Re: NGUI Iphone 4 (iOS6) performance
« Reply #6 on: May 28, 2014, 09:51:07 AM »
@ArenMook

Ah, interesting. So it would be wiser not to put for example the Font-Data into the same Atlas where all the other GUI-Sprites are knowing one would put them all under one panel, right?

jimbbq

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 25
    • View Profile
Re: NGUI Iphone 4 (iOS6) performance
« Reply #7 on: May 28, 2014, 10:31:01 AM »
I found out that the main culprit is Dynamic Fonts!!! I tried to create bitmap font, but I got the Freetype.dylib error! how do I resolve this? thanks

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI Iphone 4 (iOS6) performance
« Reply #8 on: May 29, 2014, 06:00:22 AM »
@jimbbq: Copy the FreeType.dylib library into /usr/local/lib

@BehindTheStone: You can keep them in the same atlas, but it's wise to put frequently changing widgets into their own panel, thus separating them from others.