Author Topic: UIPanel - Drawcalls priority problem  (Read 7983 times)

yotes

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
UIPanel - Drawcalls priority problem
« on: June 11, 2012, 06:15:17 PM »
I've been working all day on an interface with a pane that share two atlas, this is because I want to load an specific atlas in one moment, but I also want to use some images that are already in another atlas. Everything went OK at work, the panel worked perfectly sharing atlases, but when I tried to continue my work at home, the panel started to paint things in different order. The atlas that was already loaded is the one who has the fonts, and it has to be painted in the front of the other, that has the background. So, I assume that UIPanel makes one drawcall with all the widgets of one atlas, and then do the other drawcall for the other atlas.. at work I didn't realize of this because it just work OK, but at home, y can't see any text because the panel paints first the fonts (with the first atlas), and then the background (with the other atlas).

Is there any way to invert this? or I should avoid this kind of things?

Thanks!

rain

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 4
  • Posts: 79
    • View Profile
Re: UIPanel - Drawcalls priority problem
« Reply #1 on: June 11, 2012, 06:34:19 PM »
My workaround is to bring your widgets closer to the camera which you want to be drawn first.

yotes

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
Re: UIPanel - Drawcalls priority problem
« Reply #2 on: June 11, 2012, 06:41:55 PM »
I've tried this, but it doesn't work.. it will work for each drawcall separately but the depth is ignored from atlas to atlas :(

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: UIPanel - Drawcalls priority problem
« Reply #3 on: June 11, 2012, 06:53:00 PM »
If separate atlases are use, a different draw call is used for each. Each draw call is batched together, which means everything from atlas A will be either on top of or below atlas B widgets.

You can force one atlas to be on top, by setting the position on one or more widgets to z= -1 (localPosition). Depth does not work from atlas to atlas, only in the same panel with the same atlas - and it also determines the depth of the boxcollider that the AddCollider adds.

If you want to mix so you have something from atlas B on the bottom, then something from atlas A, and then again something from atlas B you have to use at least 2 UIPanels, since each UIpanel makes their own draw call.

yotes

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
Re: UIPanel - Drawcalls priority problem
« Reply #4 on: June 11, 2012, 06:58:12 PM »
I can`t move my widgets in Z direction, only over X or Y .. I supposed that it was because NGUI doesn't allow you to do that.. but you can?

I'm doing some checks.. and I can change the Z value on the panel, but isn't reflected in the scene view, they are stickied to the zero position on z
« Last Edit: June 11, 2012, 07:08:10 PM by yotes »

yotes

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
Re: UIPanel - Drawcalls priority problem
« Reply #5 on: June 11, 2012, 08:33:17 PM »
It's weird.. but sometimes when I open unity, the drawcalls switch priority from one to another.. works with some kind of aleatory :(

rain

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 4
  • Posts: 79
    • View Profile
Re: UIPanel - Drawcalls priority problem
« Reply #6 on: June 11, 2012, 08:44:31 PM »
Are those widgets anchored?

ENAY

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 248
    • View Profile
Re: UIPanel - Drawcalls priority problem
« Reply #7 on: June 11, 2012, 09:35:56 PM »
Is this 2D or 3D? Are you using a perspective camera?

yotes

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
Re: UIPanel - Drawcalls priority problem
« Reply #8 on: June 11, 2012, 09:39:20 PM »
Yes, well there is an empty game object that has an anchor (center in this case), then the pane that belongs to this object, but this does not have any anchor, and then the widgets inside the panel.. I tried to disable the anchor before, but I still cannot move the widgets in Z after that :/.

It's a 2d camera... orthographic 2d UI