Author Topic: [SOLVED] creating 'Parallel' the bg on the back sometimes comes to front  (Read 4903 times)

Spacez

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 26
    • View Profile
i had parallel backgrounds created using Unity Plane + Texture, but i want to reimplement them using NGUI Atlas in order to reduce some Draw Calls.

the problem is when i finished reimplementing using Atlas, then i tested the result and found that some backgrounds on the back sometimes show in the front !

here is what i tried (but didnt solve the problem :( )
- checked that each background is exactly next to each other
- reimplemented again but separating atlas depends on the layer of parallel (the 1st front use 1 atlas, 2nd front use 1 atlas, ...)
- the parallel algorithm i used works well with normal unity plane + texture


Thanks in advanced for every help,
« Last Edit: September 14, 2013, 12:09:48 PM by Spacez »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: creating 'Parallel' the bg on the back sometimes comes to front
« Reply #1 on: September 11, 2013, 09:52:54 AM »
Check the FAQ. Depth vs Z was covered a million times in this forum. Coincidently, one of NGUI 3.0.0's features fixes this difficulty outright.

Spacez

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 26
    • View Profile
Re: creating 'Parallel' the bg on the back sometimes comes to front
« Reply #2 on: September 11, 2013, 12:09:28 PM »
sry, forgot to tell that i also tried adjusting depth and z (as your mentioned in FAQ about them), unfortunately it didnt solve the problem :(


in addition, if you see the picture i attached, you may notice that it is just a part of the texture that show in front (while some part of the same texture is behind). so i guess it's not about z and depth ('cause if i adjust it in the wrong way the whole texture should be front or back, not a part of it)


thanks for the help :D

Spacez

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 26
    • View Profile
Re: creating 'Parallel' the bg on the back sometimes comes to front
« Reply #3 on: September 14, 2013, 02:21:08 AM »
bump! some help pls ;(

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: creating 'Parallel' the bg on the back sometimes comes to front
« Reply #4 on: September 14, 2013, 07:59:53 AM »
Well, it looks like you have multiple textures going and the beach one tiles right where it breaks.

I'm assuming you want the clouds to always be behind and the beach to always be in front? Have them not be next to each otehr, but the clouds at z position 10 and beach at 0. IF you're using NGUI 3.0 or 2.7 with the depth sorting enabled, set the depths like they should be and there shouldn't be a problem.

If there's stil a problem, then we need some more information to go by. How many textures are you using? How does your inspector look, what does your scripts do to the textures - maybe they move them to be at the same z position and NGUI gets confused as to which is drawn first etc.

Spacez

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 26
    • View Profile
Re: creating 'Parallel' the bg on the back sometimes comes to front
« Reply #5 on: September 14, 2013, 12:09:29 PM »
thanks for reply Nicki,

the problem has been SOLVED :)

here is what i did (in fact i missed such a simple point :( )

- i tried update my NGUI from 2.6.3 to 2.7.0 and there is 'depth sort' option enabled for me.
- as i told that, i'm creating many sets of background bundle using code (by changing widget sprite name), BUT i forgot that each of the bundle hasnt been created under the same PANEL. (i guess that is the point which NGUI confuses with the depth)
- i added some code so that each bundle will be created under the same panel (which has 'depth sort' enabled'), and the parallel works well !


ps. thanks everyone for the help :)
ps2. marked this thread as solved in case there will be someone having the same problem.