Hello Guest

Author Topic: Changing sprite makes the object overlap particle systems  (Read 5107 times)

griden

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 15
    • View Profile
Changing sprite makes the object overlap particle systems
« on: May 17, 2014, 11:30:41 pm »
If I change the sprite of an object with SetSprite(id), that object somehow starts to ignore the sortingOrder and overlaps objects it's not supposed to (particles in this case).

I do set its proper sortingLayer and sortingOrder AFTER the sprite switch (just to be sure) and I check if all values are correct.
And yes, if I don't change the sprite, everything behaves as expected.
The particle systems have higher sortingLayer and are way closer to the camera.

Any advice would be appreciated, thanks!

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Changing sprite makes the object overlap particle systems
« Reply #1 on: May 18, 2014, 06:49:02 pm »
Not seen this before. Does it still show the correct sorting order in the inspector? Does setting the drawing order again help?

griden

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: Changing sprite makes the object overlap particle systems
« Reply #2 on: May 18, 2014, 07:11:45 pm »
Yes, the new sprites have the correct order values in the inspector.
And the order is re-enforced - via code, after the sprite switch.

And I check the particle's layers/orders in runtime with console messages - everything looks fine. They have sorting layer with higher ID and I've tried some outrageous sorting order values as well.

It's really weird.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Changing sprite makes the object overlap particle systems
« Reply #3 on: May 18, 2014, 07:23:57 pm »
I wouldn't be surprised if it were a Unity bug. 4.3 is the first version of unity with the layer system in it. If you do find it to be a unity bug, please report it.

griden

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: Changing sprite makes the object overlap particle systems
« Reply #4 on: May 18, 2014, 10:39:56 pm »
Ok, it appears that the reason is that the new sprite is 100% WHITE.
If I start adding some grey or any other colour, things are getting better. Above 5% grey the problem disappears.

It might be a bug, or something about computer graphics that I don't know   :-\ .
« Last Edit: May 18, 2014, 10:42:54 pm by griden »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Changing sprite makes the object overlap particle systems
« Reply #5 on: May 19, 2014, 11:13:20 am »
What happens if you start off with this sprite? The color can't affect sorting, but if it was white, the particles are not going to draw on top if they're set to additive as its already as bright as it can be.

griden

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: Changing sprite makes the object overlap particle systems
« Reply #6 on: May 19, 2014, 11:32:59 am »
Sorry I forgot to mention - yes, the white colour seems to be the sole reason for the problem. Nothing to do with the sprite switch.
And yes, those particles have additive shaders.

Well I learned something new. Thanks!