Author Topic: Unity performance and NGUI - a few questions  (Read 3439 times)

Dick the Bagnificent

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Unity performance and NGUI - a few questions
« on: October 07, 2014, 10:00:44 AM »
Hello People.

Been using NGUI (3.7.1) for about a month now and I'm very happy about it. I have some questions about performance of Unity and if (and hopefully how) NGUI can be used to improve the performance. There's no problem with the performance of the NGUI level script execution.

We're making an application that has to display high-resolution pages on tablets (1536x2048, ipad native). Since we'd like it to be running on low-memory systems too (and also have non-texture assets like sounds), we're loading and unloading these pages from prefabs. I started out using Resources.Load, and unsurprising got a performance drop on the occasions where I load new pages.

I updated unity to 4.5.4 and got to play around with Resources.LoadAsync and co-routines, which severely reduced the spikes on page load. There's still the occasional spike though so I fired up the profiler to see what creates it. Turns out it was the Loading.ReadObject when called from Material.GetTexture(). Again, not surprising since we're running on low-performance systems and the textures are fairly high resolution.

I was thinking that since it's NGUIs atlas maker that I used to make the materials that are loading, you experienced NGUI people might have some clever tricks up your sleeves ...

Anyhow, question:

1) Is there anything optimization-wise I can do about the materials that NGUI's atlas maker creates?

2) Will Material.GetTexture() be slower if the texture is part of a larger atlas? In that case, maybe splitting the textures into more atlases would mean smaller lag spikes more frequently, which would be less noticeable.

3) I'm assuming that cutting my texture size in half would improve on this (and make our graphics artist cry). Am I correct in assuming this? (The performance part, not the artist part).

4) Anything else about my approach that's stupid?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Unity performance and NGUI - a few questions
« Reply #1 on: October 07, 2014, 10:45:31 AM »
If you have large textures, don't even bother placing them into a texture atlas. Texture atlases are for bundling a lot of small textures into one place. Have a look at your texture atlas and remove any large ones out of it. In Windward I use a single 1024x1024 texture for everything, with 274 sprites inside. Most are 50x50, some less, some more. I even moved such things as company logo and game logo out of it, since they aren't going to be visible that often, so doesn't make sense to have them take up the texture memory in the atlas.

Dick the Bagnificent

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: Unity performance and NGUI - a few questions
« Reply #2 on: October 08, 2014, 06:22:01 AM »
Thanks, will give it a try without atlases.