Author Topic: How to get particle system above NGUI widget  (Read 2723 times)

wijesijp

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 6
    • View Profile
How to get particle system above NGUI widget
« on: December 14, 2015, 11:37:15 PM »
In my game i have a NGUI UI widget at the bottom of the screen with some sprites etc. 
I what a particle system to appear above that.

I have seen this port about this. But I have trouble getting it to work
http://www.tasharen.com/forum/index.php?topic=776.msg34546#msg34546
 

I did following test to whether renderq can be used for my task ..

In my game I set UI Root Render Q to 3000 with sorting order 0
Then I add a NGUI sprite to the game

Then I add a sprite to the game and following script to it

  1.     Renderer ren;
  2.     public UIWidget target;
  3.  
  4.     void Start () {
  5.         ren = gameObject.GetComponent<SpriteRenderer>();
  6.         ren.material.renderQueue = 4000;
  7.     }
  8.        
  9.         void Update () {
  10.  
  11.         if (target == null || target.drawCall == null)
  12.             return;
  13.  
  14.         print("sprite " + ren.material.renderQueue);
  15.         print("NGUI " + target.drawCall.renderQueue);
  16.     }
  17.  

I can see from the output my sprite has 4000 render q and NGUI sprite has 3000 render q
but still my sprite is behind NGUI sprite ...

Can anyone provide some help ?
« Last Edit: December 16, 2015, 03:08:59 AM by wijesijp »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How to get particle system above NGUI widget
« Reply #1 on: December 16, 2015, 03:07:54 AM »
Are they drawn by the same camera?

wijesijp

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: How to get particle system above NGUI widget
« Reply #2 on: December 16, 2015, 03:20:07 AM »
NO
NGUI uses it's camera and my sprite use the Main camera in game

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How to get particle system above NGUI widget
« Reply #3 on: December 16, 2015, 10:34:26 PM »
Well there's your problem then.

Two different cameras means it's completely impossible to make things intermix.

First one camera draws everything it sees, then another camera draws everything it sees. Logic.

wijesijp

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: How to get particle system above NGUI widget
« Reply #4 on: December 16, 2015, 10:51:25 PM »
Yes you are right
I add the particle layer to the NGUI camera and the code worked.