Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: pretender on December 19, 2012, 05:10:57 PM

Title: NGUI troubles with older devices, help me resolve!
Post by: pretender on December 19, 2012, 05:10:57 PM
Hi! I used NGUI in one of my projects, it seems that it does not work good on older devices or I dont know how to use it properly
i suspect on three draggable panels that have softclipping on them. I dont know the right combination of shaders and tricks to get it right on, for example older samsung galaxy s2 type of device.

the things i know i can optimize:
1.) disable nguis that are off the screen (it reports less draw calls when they are not visible, but it seems that fps drops when they are disabled), i am not sure how to disable ngui elements and game objects with NGUITools.SetActive(GO,false/true)
because when it is disabled then i cannot find it with name again and i have to maintain reference to it.
2.) try to rearrange things so that i dont get too much overdraws (if i understood correctly no overlapping, or it should be avoided, stacking sprites on top of them, but this is something that i cannot avoid since there must be background to draw onto). One question about this, since i need background for draggable panels with collider to work, can those backgrounds have alpha set to zero so they are not visible but not count for a performance drop?
3.) use only one atlas for everything

things i am not certain about
1.) what shaders for clippedpanel i should use if i want to use it on mobile devices (older, but not that old)?
what else i should take into account, how many elements on the draggable panel, sprites, etc...
2.) what else i should take into account to make ngui fast enough for older devices.

i have to say that ngui is very good gui system but i do not have enough experience to make it work efficiently, i would appreciate your help!


thank you!

one more things to say, when profiling i see UIPanel.LateUpdate as more then 40%, is this a problem?
Title: Re: NGUI troubles with older devices, help me resolve!
Post by: ArenMook on December 20, 2012, 01:29:26 AM
LatePanel taking that much time implies that you have something moving or changing in one of your panels. When something changes, it affects everything else -- and that's slow. Move whatever is changing out into its own panel to make it faster, or get rid of it altogether.

Soft or Alpha generally perform best on mobile devices. Hard clip has really bad performance on some android devices.
Title: Re: NGUI troubles with older devices, help me resolve!
Post by: Nicki on December 20, 2012, 05:36:06 AM
Alpha is the fastest clipping on mobiles, followed by Hard and lastly soft. Hard has the unfortunate sideeffect of just plain breaking on certain devices, so don't use that.

Use alpha clipping.

If your UIPanel.LateUpdate() it taking a lot of time, figure out which pabel is doing it - if you're animating something inside the panel, then it rebuilds the mesh every update which is quite costly. COnsider splitting out your animating elements into their own panel and animat that panel.

Do note, that there's a big difference between animating the panel itself and animating a child under it. Animating the panel is way faster.
Title: Re: NGUI troubles with older devices, help me resolve!
Post by: pretender on December 20, 2012, 06:04:23 AM
ok, here is additional explanation
i am generating elements under draggable panel

structure is like this:

Anchor (right)
  HolderForPanel (this is where animation is - sliding in out of the screen)
   HolderForDraggablePanel (where controller script is)
    DraggablePanel (marked as PanelTool, static checked, depthpass checked,alpha clip used, spring and momentum used)
     Grid (where elements are generated)
       20 - 30 elements in the grid (parts with colliders have UIDraggablePanelContents attached)

is this setup correctly (all elements in the grid should have UIDraggablePanelContents?)

things i have noticed is that it renders very fast when it stops moving, when it is dragged fps drops from ~500 to ~400 (Editor) for a moment, but when it stops moving it renders very fast!), also using only momentum without spring seems to speed up things, is this correct?

i removed all hovers,scales,color changes and onpress tweens. does this mean it will be static?

thanks for help!
Title: Re: NGUI troubles with older devices, help me resolve!
Post by: ArenMook on December 20, 2012, 09:48:38 AM
UIDraggablePanel should be on the panel. UIDragPanelContents should be on collider(s) within the panel. Assuming nothing changes within the panel, performance should be pretty fast when you drag it.