Author Topic: label using an extra draw-call for no apparent reason  (Read 5732 times)

alexv

  • Newbie
  • *
  • Thank You
  • -Given: 10
  • -Receive: 1
  • Posts: 22
    • View Profile
label using an extra draw-call for no apparent reason
« on: October 29, 2014, 10:28:52 AM »
Hey there, I've got a widget on its own panel, and for drawing it uses 2 sprites and 6 labels with a total of 3 unity dynamic fonts.

I was expecting to get 4 draw calls to get that widget drawn:
1 draw call for all the sprites + 1 draw call per font.

so, this widget has 3 labels using the same font, and ngui groups them in the same drawcall, really neat!

so far so good.....but....I've noticed one of my labels that shares the same font with the other 2 labels, is being drawn on its own draw-call for no reason...and that specific label is the only one using "Expand Height" overflow.

Weird thing is, if I disable and re-enable that label, it fixes the draw-call issue, grouping it back with the other 2 labels that share the same font, so as a workaround, I have set a script that performs:

void Start() {
   myLbl.enabled=false;
  myLbl.enabled=true;
}

this fixes the issue, but, why is it happening in the first place?

thanks in advance aren!


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: label using an extra draw-call for no apparent reason
« Reply #1 on: October 30, 2014, 11:35:01 AM »
Sandwiching things means creation of extra draw calls. You need to group your depth layers. For example all atlas-using widgets use depth of 0 to 50. All dynamic labels using font A use depths 51 to 100. All dynamic labels using font B use depths 101 to 150, etc.

Every time you interrupt the material depth continuity, NGUI has to create a new draw call in order to draw things in the order you placed them in.

Lastly, ensure that you don't share depth values. If you have atlas-using sprite on depth XYZ and a dynamic label on the same depth XYZ, which one will be drawn first is undefined.

alexv

  • Newbie
  • *
  • Thank You
  • -Given: 10
  • -Receive: 1
  • Posts: 22
    • View Profile
Re: label using an extra draw-call for no apparent reason
« Reply #2 on: October 30, 2014, 07:40:36 PM »
ahhh, I see thanks for the clarification! I'm mixing different fonts on the same layer, so that's probably it, now I understand why disable-enable fixed it :)
I will re-organize this depth chaos :)

thanks aren!