Author Topic: Why are my graphics disappearing?  (Read 1876 times)

motionsmith

  • Guest
Why are my graphics disappearing?
« on: April 11, 2013, 05:22:47 PM »
Sometimes, as I scroll around (either with the camera or via a draggable panel), my graphics disappear. This is only ever a problem between graphics in panels that are layered using z-depth.

The problem seems to more-less fix itself when I use z-depth values that are about 15 units apart.

I am only using one atlas, but I have to use z-depth because I have multiple UIPanels and UITextures (neither of which adhere to the UIWidget "depth" property).

I'd like more info about this problem because it's a reliability/debugging nightmare, especially as I drag objects around and change SD/HD atlases.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Why are my graphics disappearing?
« Reply #1 on: April 11, 2013, 07:24:13 PM »
If your graphics is ordered by Z position and it's in a clipped panel, then you may have only move a few of the materials that need to be in the front forward. If there is an instant where you don't have something from the material that needs to be in the front at a lower Z, then the whole thing will be pushed under the background.

This means, for instance, if you have a background at 0 that is always in the screen, and you scroll a bunch of widgets from your other atlas around - if only a single widget in the panel is set to z = -1, then when that particular widget is clipped and removed the rest of the widgets can fall below the background in draw order.

Does that make sense?

motionsmith

  • Guest
Re: Why are my graphics disappearing?
« Reply #2 on: April 11, 2013, 07:33:20 PM »
It almost makes sense. But it sounds like you're describing my problem (which is good), and at least it gives me something to work off.

The only thing I move forward are the things that aren't in an atlas on that panel (such as colliders and UITextures). I appreciate your explanation, even if I don't fully understand it. I actually know NGUI quite well, so if you (or someone) is able to further explain, that would be great.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Why are my graphics disappearing?
« Reply #3 on: April 12, 2013, 07:31:54 PM »
Alright, well, the thing is that your background element likely is in the same z-position as some of your other elements in different materials (another atlas, a UITexture, or a different panel). When the few elements that you have put forward in the screen are on screen, everything from that particular drawcall (material) is drawn on top of the background. When one of those elements are clipped, Unity gets confused since it has two draw calls that should be at the same time, so it chooses one for all intents and purposes, at random to draw first - and that's the one you don't want. :)

The solution is to move all different draw calls that need to be on top forward on z position, so they would all be ordered even if some of them are temporarily removed.